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
*/
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) {
return AngleVersion.D3D11;
}
if (glslVer >= 100) {
return AngleVersion.D3D9;
if (glslVer >= 300) {
return AngleVersion.D3D11;
}
if (glslVer >= 100) {
return AngleVersion.D3D9;
}
} catch (e) {
return AngleVersion.NotAvailable;
}
}
@ -68,16 +72,19 @@ function detectGl(shaderSource: string) {
* @returns
*/
function detectBackend(str) {
try {
if (str.match(/metal::float4/)) {
return AngleVersion.Metal;
}
if (str.match(/metal::float4/)) {
return AngleVersion.Metal;
if (str.match(/VS_OUTPUT main\(/)) {
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>
<!-- ANGLE warning for chrome/edge -->
<div v-if="warnings.angleBackend" class="flex flex-column">
<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/>
<small> This causes videos to be stretched incorrectly.
This is a bug with <template v-if="BrowserDetect.edge">Edge</template><template v-else>Chrome</template>, not with this addon.</small><br/>
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 class="warning-lite">
<template v-if="BrowserDetect.edge">Edge</template><template v-else>Chrome</template>'s hardware acceleration has a history of bugs that may
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.
</div> -->
</div>
<div
@ -227,7 +225,8 @@ import { detectANGLEBackend, AngleVersion } from '../ext/lib/angle-detect/detect
export default {
data () {
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 {
selectedTab: 'video',