fix angle detection

This commit is contained in:
Tamius Han 2024-01-28 13:01:16 +01:00
parent 41bf4d2764
commit a7302fee4b
2 changed files with 28 additions and 22 deletions

View File

@ -18,15 +18,19 @@ export enum AngleVersion {
* @returns * @returns
*/ */
function detectDX(shaderSource: string) { function detectDX(shaderSource: string) {
const glsl = shaderSource.match(/#version (\d+)( es)?$/m); try {
const glsl = shaderSource.match(/#version (\d+)( es)?$/m);
const glslVer = +glsl[1]; const glslVer = +glsl[1];
if (glslVer >= 300) { if (glslVer >= 300) {
return AngleVersion.D3D11; return AngleVersion.D3D11;
} }
if (glslVer >= 100) { if (glslVer >= 100) {
return AngleVersion.D3D9; return AngleVersion.D3D9;
}
} catch (e) {
return AngleVersion.NotAvailable;
} }
} }
@ -68,16 +72,19 @@ function detectGl(shaderSource: string) {
* @returns * @returns
*/ */
function detectBackend(str) { function detectBackend(str) {
try {
if (str.match(/metal::float4/)) {
return AngleVersion.Metal;
}
if (str.match(/metal::float4/)) { if (str.match(/VS_OUTPUT main\(/)) {
return AngleVersion.Metal; return detectDX(str);
}
return detectGl(str);
} catch (e) {
return AngleVersion.NotAvailable;
} }
if (str.match(/VS_OUTPUT main\(/)) {
return detectDX(str);
}
return detectGl(str);
} }
/** /**

View File

@ -22,12 +22,10 @@
</div> </div>
<!-- ANGLE warning for chrome/edge --> <!-- ANGLE warning for chrome/edge -->
<div v-if="warnings.angleBackend" class="flex flex-column"> <div v-if="warnings.angleBackend" class="flex flex-column">
<div class="warning-lite"> <!-- <div class="warning-lite">
<b style="padding-left: 0.5rem">Hardware acceleration in <template v-if="BrowserDetect.edge">Edge</template><template v-else>Chrome</template> is broken</b><br/> <template v-if="BrowserDetect.edge">Edge</template><template v-else>Chrome</template>'s hardware acceleration has a history of bugs that may
<small> This causes videos to be stretched incorrectly. cause videos to be stretched incorrectly. If videos are stretched incorrectly, visit <code style="background-color: rgba(255,128,64, 0.2)"><template v-if="BrowserDetect.edge">edge</template><template v-else>chrome</template>://flags#use-angle</code> and try changing this option to <b>D3D9</b>, <b>OpenGL</b>, or something other than the currently selected option.
This is a bug with <template v-if="BrowserDetect.edge">Edge</template><template v-else>Chrome</template>, not with this addon.</small><br/> </div> -->
To fix the problem, visit <code style="background-color: rgba(255,128,64, 0.2)"><template v-if="BrowserDetect.edge">edge</template><template v-else>chrome</template>://flags#use-angle</code> and choose <b>D3D9</b> or <b>OpenGL</b> from available options.
</div>
</div> </div>
<div <div
@ -227,7 +225,8 @@ import { detectANGLEBackend, AngleVersion } from '../ext/lib/angle-detect/detect
export default { export default {
data () { data () {
const angleBackend = detectANGLEBackend(); const angleBackend = detectANGLEBackend();
const gibAngleWarning = BrowserDetect.anyChromium && angleBackend !== AngleVersion.OpenGL && angleBackend !== AngleVersion.D3D9; // const gibAngleWarning = BrowserDetect.anyChromium && angleBackend !== AngleVersion.OpenGL && angleBackend !== AngleVersion.D3D9;
const gibAngleWarning = false;
return { return {
selectedTab: 'video', selectedTab: 'video',