Flycast: [OIT] Crashes on boot (Mesa 18.2-git AMDGPU - Tonga)

Created on 11 Jul 2018  路  9Comments  路  Source: libretro/flycast

Log:
Invalid GD-DMA start, SB_GDEN=0.Ingoring it.
SPI : unknown ? [0x70]
SPI : unknown ? [0x71]
sh4io: Invalid read access @@ 00000030
Freeing fpcb
Invalid GD-DMA start, SB_GDEN=0.Ingoring it.
Freeing fpcb
Freeing fpcb
new tactx
new tactx
Shader: failed to compile
0:271(22): error: opaque variables cannot be operands of the ?: operator

Shader linking: failed to link
(51 bytes), - error: linking with uncompiled/unspecialized shader -
DEBUGBREAK!

glxinfo:
OpenGL vendor string: X.Org
OpenGL renderer string: AMD Radeon R9 200 Series (TONGA, DRM 3.23.0, 4.16.0-2-amd64, LLVM 6.0.1)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.2.0-devel (git-688d757e15)
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 4.4 (Compatibility Profile) Mesa 18.2.0-devel (git-688d757e15)
OpenGL shading language version string: 4.40
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

As expected, it does not boot at all using Mesa 18.1.3 due to lack of OGL 4.x compatibility profile.

Most helpful comment

Backported as well.

All 9 comments

OpenGL version string: 4.4 (Compatibility Profile) Mesa 18.2.0-devel (git-688d757e15)

You do have a 4.x compat profile... AMD's shader compiler just doesn't like one of the shaders in reicast... that is a completely different issue.

Shader log:
Shader: failed to compile
0:275(22): error: opaque variables cannot be operands of the ?: operator

Failed shader source: #version 430

layout(r32ui, binding = 4) uniform coherent restrict uimage2D abufferPointerImg;
struct Pixel {
mediump vec4 color;
mediump float depth;
int seq_num;
uint next;
};

define EOL 0xFFFFFFFFu

layout (binding = 0, std430) coherent restrict buffer PixelBuffer {
Pixel pixels[];
};
layout(binding = 0, offset = 0) uniform atomic_uint buffer_index;

define ZERO 0

define ONE 1

define OTHER_COLOR 2

define INVERSE_OTHER_COLOR 3

define SRC_ALPHA 4

define INVERSE_SRC_ALPHA 5

define DST_ALPHA 6

define INVERSE_DST_ALPHA 7

uint getNextPixelIndex()
{
uint index = atomicCounterIncrement(buffer_index);
if (index >= pixels.length())
discard;

return index;
}

void setFragDepth(void)
{
highp float w = 100000.0 * gl_FragCoord.w;
gl_FragDepth = 1.0 - log2(1.0 + w) / 34.0;
}
struct PolyParam {
int first;
int count;
int texid;
int tsp;
int tcw;
int pcw;
int isp;
float zvZ;
int tileclip;
int tsp1;
int tcw1;
int texid1;
};
layout (binding = 1, std430) buffer TrPolyParamBuffer {
PolyParam tr_poly_params[];
};

int getSrcBlendFunc(const PolyParam pp, bool area1)
{
return ((area1 ? pp.tsp1 : pp.tsp) >> 29) & 7;
}

int getDstBlendFunc(const PolyParam pp, bool area1)
{
return ((area1 ? pp.tsp1 : pp.tsp) >> 26) & 7;
}

bool getSrcSelect(const PolyParam pp, bool area1)
{
return (((area1 ? pp.tsp1 : pp.tsp) >> 25) & 1) != 0;
}

bool getDstSelect(const PolyParam pp, bool area1)
{
return (((area1 ? pp.tsp1 : pp.tsp) >> 24) & 1) != 0;
}

int getFogControl(const PolyParam pp, bool area1)
{
return ((area1 ? pp.tsp1 : pp.tsp) >> 22) & 3;
}

bool getUseAlpha(const PolyParam pp, bool area1)
{
return (((area1 ? pp.tsp1 : pp.tsp) >> 20) & 1) != 0;
}

bool getIgnoreTexAlpha(const PolyParam pp, bool area1)
{
return (((area1 ? pp.tsp1 : pp.tsp) >> 19) & 1) != 0;
}

int getShadingInstruction(const PolyParam pp, bool area1)
{
return ((area1 ? pp.tsp1 : pp.tsp) >> 6) & 3;
}

int getDepthFunc(const PolyParam pp)
{
return (pp.isp >> 29) & 7;
}

bool getDepthMask(const PolyParam pp)
{
return ((pp.isp >> 26) & 1) != 1;
}

bool getShadowEnable(const PolyParam pp)
{
return ((pp.pcw >> 7) & 1) != 0;
}

int getPolyNumber(const Pixel pixel)
{
return pixel.seq_num & 0x3FFFFFFF;
}

bool isShadowed(const Pixel pixel)
{
return (pixel.seq_num & 0x80000000) == 0x80000000;
}

bool isTwoVolumes(const PolyParam pp)
{
return pp.tsp1 != 0xFFFFFFFF || pp.tcw1 != 0xFFFFFFFF;
}

define cp_AlphaTest 0

define pp_ClipTestMode 0

define pp_UseAlpha 1

define pp_Texture 1

define pp_IgnoreTexA 0

define pp_ShadInstr 3

define pp_Offset 0

define pp_FogCtrl 2

define pp_TwoVolumes 0

define pp_DepthFunc 6

define pp_Gouraud 0

define pp_BumpMap 0

define PASS 3

define PI 3.1415926

#if PASS <= 1
out vec4 FragmentColor;
#endif

if pp_TwoVolumes == 1

define IF(x) if (x)

else

define IF(x)

endif

if pp_Gouraud == 0

define INTERPOLATION flat

else

define INTERPOLATION smooth

endif

/* Shader program params/
/
gles has no alpha test stage, so its emulated on the shader */
uniform float cp_AlphaTestValue;
uniform vec4 pp_ClipTest;
uniform vec3 sp_FOG_COL_RAM,sp_FOG_COL_VERT;
uniform float sp_FOG_DENSITY;
uniform float shade_scale_factor;
uniform sampler2D tex0, tex1;
layout(binding = 5) uniform sampler2D fog_table;
uniform int pp_Number;
uniform usampler2D shadow_stencil;
uniform sampler2D DepthTex;
uniform lowp float trilinear_alpha;

uniform ivec2 blend_mode[2];

if pp_TwoVolumes == 1

uniform bool use_alpha[2];
uniform bool ignore_tex_alpha[2];
uniform int shading_instr[2];
uniform int fog_control[2];

endif

/* Vertex input*/
INTERPOLATION in lowp vec4 vtx_base;
INTERPOLATION in lowp vec4 vtx_offs;
in mediump vec2 vtx_uv;
INTERPOLATION in lowp vec4 vtx_base1;
INTERPOLATION in lowp vec4 vtx_offs1;
in mediump vec2 vtx_uv1;
float fog_mode2( float w)
{
float z = clamp(w * sp_FOG_DENSITY, 1.0, 255.9999);
uint i = uint(floor(log2(z)));
float m = z * 16 / pow(2, i) - 16;
float idx = floor(m) + i * 16 + 0.5;
vec4 fog_coef = texture(fog_table, vec2(idx / 128, 0.75 - (m - floor(m)) / 2));
return fog_coef.a;
}
void main()
{
setFragDepth();

#if PASS == 3
// Manual depth testing
highp float frontDepth = texture(DepthTex, gl_FragCoord.xy / textureSize(DepthTex, 0)).r;
#if pp_DepthFunc == 0 // Never
discard;
#elif pp_DepthFunc == 1 // Greater
if (gl_FragDepth <= frontDepth)
discard;
#elif pp_DepthFunc == 2 // Equal
if (gl_FragDepth != frontDepth)
discard;
#elif pp_DepthFunc == 3 // Greater or equal
if (gl_FragDepth < frontDepth)
discard;
#elif pp_DepthFunc == 4 // Less
if (gl_FragDepth >= frontDepth)
discard;
#elif pp_DepthFunc == 5 // Not equal
if (gl_FragDepth == frontDepth)
discard;
#elif pp_DepthFunc == 6 // Less or equal
if (gl_FragDepth > frontDepth)
discard;
#endif
#endif

// Clip outside the box 
#if pp_ClipTestMode==1 
    if (gl_FragCoord.x < pp_ClipTest.x || gl_FragCoord.x > pp_ClipTest.z 
            || gl_FragCoord.y < pp_ClipTest.y || gl_FragCoord.y > pp_ClipTest.w) 
        discard; 
#endif 
// Clip inside the box 
#if pp_ClipTestMode==-1 
    if (gl_FragCoord.x >= pp_ClipTest.x && gl_FragCoord.x <= pp_ClipTest.z 
            && gl_FragCoord.y >= pp_ClipTest.y && gl_FragCoord.y <= pp_ClipTest.w) 
        discard; 
#endif

vec4 color = vtx_base;
vec4 offset = vtx_offs;
mediump vec2 uv = vtx_uv;
bool area1 = false;
ivec2 cur_blend_mode = blend_mode[0];

#if pp_TwoVolumes == 1 
  bool cur_use_alpha = use_alpha[0]; 
  bool cur_ignore_tex_alpha = ignore_tex_alpha[0]; 
  int cur_shading_instr = shading_instr[0]; 
  int cur_fog_control = fog_control[0]; 
    #if PASS == 1 
        uvec4 stencil = texture(shadow_stencil, gl_FragCoord.xy / textureSize(shadow_stencil, 0)); 
        if (stencil.r == 0x81u) { 
            color = vtx_base1; 
            offset = vtx_offs1; 
            uv = vtx_uv1; 
            area1 = true; 
        cur_blend_mode = blend_mode[1]; 
        cur_use_alpha = use_alpha[1]; 
        cur_ignore_tex_alpha = ignore_tex_alpha[1]; 
        cur_shading_instr = shading_instr[1]; 
        cur_fog_control = fog_control[1]; 
        } 
    #endif
#endif

#if pp_UseAlpha==0 || pp_TwoVolumes == 1 
  IF(!cur_use_alpha) 
        color.a=1.0; 
#endif

#if pp_FogCtrl==3 || pp_TwoVolumes == 1 // LUT Mode 2
IF(cur_fog_control == 3)
color=vec4(sp_FOG_COL_RAM.rgb,fog_mode2(gl_FragCoord.w));
#endif
#if pp_Texture==1
{
vec4 texcol=texture(area1 ? tex1 : tex0, uv);

  #if pp_BumpMap == 1 
        float s = PI / 2.0 * (texcol.a * 15.0 * 16.0 + texcol.r * 15.0) / 255.0; 
        float r = 2.0 * PI * (texcol.g * 15.0 * 16.0 + texcol.b * 15.0) / 255.0; 
        texcol.a = clamp(vtx_offs.a + vtx_offs.r * sin(s) + vtx_offs.g * cos(s) * cos(r - 2.0 * PI * vtx_offs.b), 0.0, 1.0); 
        texcol.rgb = vec3(1.0, 1.0, 1.0);    
    #else
        #if pp_IgnoreTexA==1 || pp_TwoVolumes == 1 
            IF(cur_ignore_tex_alpha) 
                texcol.a=1.0;    
        #endif

        #if cp_AlphaTest == 1 
            if (cp_AlphaTestValue>texcol.a) discard;
        #endif  
    #endif
  #if pp_ShadInstr==0 || pp_TwoVolumes == 1 // DECAL 
  IF(cur_shading_instr == 0) 
    { 
     color=texcol; 
    } 
    #endif
  #if pp_ShadInstr==1 || pp_TwoVolumes == 1 // MODULATE 
  IF(cur_shading_instr == 1) 
    { 
        color.rgb*=texcol.rgb; 
        color.a=texcol.a; 
    } 
    #endif
  #if pp_ShadInstr==2 || pp_TwoVolumes == 1 // DECAL ALPHA 
  IF(cur_shading_instr == 2) 
    { 
        color.rgb=mix(color.rgb,texcol.rgb,texcol.a); 
    } 
    #endif
  #if  pp_ShadInstr==3 || pp_TwoVolumes == 1 // MODULATE ALPHA 
  IF(cur_shading_instr == 3) 
    { 
        color*=texcol; 
    } 
    #endif

    #if pp_Offset==1 && pp_BumpMap == 0 
    { 
     color.rgb += offset.rgb; 
     #if pp_FogCtrl == 1 || pp_TwoVolumes == 1  // Per vertex 
        IF(cur_fog_control == 1) 
           color.rgb=mix(color.rgb, sp_FOG_COL_VERT.rgb, offset.a); 
        #endif
    } 
    #endif
} 
#endif

#if PASS == 1 && pp_TwoVolumes == 0
uvec4 stencil = texture(shadow_stencil, gl_FragCoord.xy / textureSize(shadow_stencil, 0));
if (stencil.r == 0x81u)
color.rgb *= shade_scale_factor;
#endif
#if pp_FogCtrl==0 || pp_TwoVolumes == 1 // LUT
IF(cur_fog_control == 0)
{
color.rgb=mix(color.rgb,sp_FOG_COL_RAM.rgb,fog_mode2(gl_FragCoord.w));
}
#endif
color *= trilinear_alpha;

#if cp_AlphaTest == 1 
  color.a=1.0; 
#endif

//color.rgb=vec3(gl_FragCoord.w * sp_FOG_DENSITY / 128.0);

#if PASS == 1

FragmentColor = color;
#elif PASS > 1
// Discard as many pixels as possible
switch (cur_blend_mode.y) // DST
{
case ONE:
switch (cur_blend_mode.x) // SRC
{
case ZERO:
discard;
case ONE:
case OTHER_COLOR:
case INVERSE_OTHER_COLOR:
if (color == vec4(0.0))
discard;
break;
case SRC_ALPHA:
if (color.rgb == vec3(0.0) || color.a == 0)
discard;
break;
case INVERSE_SRC_ALPHA:
if (color.rgb == vec3(0.0) || color.a == 1)
discard;
break;
}
break;
case OTHER_COLOR:
if (cur_blend_mode.x == ZERO && color == vec4(1.0))
discard;
break;
case INVERSE_OTHER_COLOR:
if (cur_blend_mode.x <= SRC_ALPHA && color == vec4(0.0))
discard;
break;
case SRC_ALPHA:
if ((cur_blend_mode.x == ZERO || cur_blend_mode.x == INVERSE_SRC_ALPHA) && color.a == 1.0)
discard;
break;
case INVERSE_SRC_ALPHA:
switch (cur_blend_mode.x) // SRC
{
case ZERO:
case SRC_ALPHA:
if (color.a == 0.0)
discard;
break;
case ONE:
case OTHER_COLOR:
case INVERSE_OTHER_COLOR:
if (color == vec4(0.0))
discard;
break;
}
break;
}

  ivec2 coords = ivec2(gl_FragCoord.xy); 
  uint idx =  getNextPixelIndex(); 
  Pixel pixel; 
  pixel.color = color; 
  pixel.depth = gl_FragDepth; 
  pixel.seq_num = pp_Number; 
  pixel.next = imageAtomicExchange(abufferPointerImg, coords, idx); 
  pixels[idx] = pixel; 

  discard; 

#endif

}
Shader linking: failed to link
(51 bytes), - error: linking with uncompiled/unspecialized shader -
DEBUGBREAK!

it looks like flyinghead is making much more improvements and fixes.
perhaps twinaphex should look into backporting more stuff.

I don't think he has missed a single one so far ;)

Backported the latest commits by @flyinghead. Guess you have to retry this with a nightly core within a few hours.

Backported as well.

That fixed it. Thanks!

Was this page helpful?
0 / 5 - 0 ratings