2016-07-20 10:13 GMT+02:00 Henri Verbeet hverbeet@gmail.com:
On 20 July 2016 at 00:33, Matteo Bruni mbruni@codeweavers.com wrote:
@@ -5848,7 +5850,7 @@ static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter *adapter) ops->generic[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2fv; ops->generic[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib3fv; ops->generic[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4fv;
- if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
- if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] = generic_d3dcolor; else ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] =
This looks wrong. When ARB_vertex_array_bgra is not supported, shaders swizzle the corresponding input registers (see also shader_glsl_swizzle_to_str() and shader_arb_get_swizzle()), so the attribute upload code shouldn't.
It's a bit more convoluted than that. When ARB_vertex_array_bgra is not supported, FFP draws usually fall back to immediate mode because of the check in context_update_stream_info(). There is no shader swizzling in that case so we need to swizzle when uploading the attribute. If ARB_vertex_array_bgra is supported we never need to swizzle the attribute so the above change seems at least a fix for that case (although if ARB_vertex_array_bgra is supported we generally don't fallback to immediate mode either, so that doesn't matter much in practice). context_update_stream_info() only checks for DIFFUSE and SPECULAR though so I guess if other attributes use D3DCOLOR we're currently screwed.
The immediate mode check is in the !VS-only branch so it would not apply to non-FFP draws. Those get the shader swizzle instead and thus work fine. I guess there is an exception here too which is instanced draws when both ARB_vertex_array_bgra and ARB_instanced_arrays are missing AND one of the instance attributes is D3DCOLOR.
Eventually for GL ES (which I think doesn't have anything equivalent to ARB_vertex_array_bgra) we'll need to always handle this in the shader since we can't fallback to immediate mode there. I guess I'll try to write a patch going in that direction since it should also clean things up WRT the above cases on desktop OpenGL.