http://bugs.winehq.org/show_bug.cgi?id=32096
--- Comment #3 from guillaum.bouchard@gmail.com 2012-10-30 04:45:18 CDT --- (In reply to comment #2)
Well, we have most of that, see e.g. wined3d_buffer_preload() and shader_glsl_swizzle_to_str().
Apparently wined3d_buffer_preload is only used for data inside *vertex buffer* (ie: VBO in GL, I don't know the d3d nomenclature).
This part of the WoW code appears to use *main memory buffer* (ie: vertex array in GL).
For shader_glsl_swizzle_to_str, I did not get where it is called and why. I'll try to understand that part of wined3d tonight.
You should probably figure out why that code doesn't get used for you.
I did a small test, using:
------------------------------- diff -r f1ba8a33d138 src/wine/dlls/wined3d/device.c --- a/src/wine/dlls/wined3d/device.c Tue Oct 30 00:15:15 2012 +0100 +++ b/src/wine/dlls/wined3d/device.c Tue Oct 30 08:25:10 2012 +0100 @@ -436,8 +436,10 @@ } else { + int bgra_supported = gl_info->supported[ARB_VERTEX_ARRAY_BGRA]; + bgra_supported = 1; WORD slow_mask = (1 << WINED3D_FFP_PSIZE); - slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] + slow_mask |= -!bgra_supported & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR));
if ((stream_info->position_transformed || (stream_info->use_map & slow_mask)) && !stream_info->all_vbo) ------------------------------
(ie: I replaced the bgra_supported value, which is 0 on my computer, by one).
Automatically I got the speedup at the cost of swapped R and B component. The amazing part is that because the rest of the code is not aware of the fact that the implementation has ARB_VERTEX_ARRAY_BGRA, it does not try to use glColorPointer(GL_BGRA, ...) and hence does not crash the program.
By doing a more subtle change:
Always enable ARB_VERTEX_ARRAY_BGRA: ------------------------------------------------------ diff -r 69f3e069092b src/wine/dlls/wined3d/directx.c --- a/src/wine/dlls/wined3d/directx.c Tue Oct 30 08:31:01 2012 +0100 +++ b/src/wine/dlls/wined3d/directx.c Tue Oct 30 08:37:39 2012 +0100 @@ -2737,6 +2737,7 @@ TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n"); gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE; } + gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE; if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC]) { TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n"); -------------------------------------------------------
Change the call to glColorPointer:
---------------------------------------------------------- diff -r 69f3e069092b src/wine/dlls/wined3d/utils.c --- a/src/wine/dlls/wined3d/utils.c Tue Oct 30 08:31:01 2012 +0100 +++ b/src/wine/dlls/wined3d/utils.c Tue Oct 30 08:37:39 2012 +0100 @@ -1601,8 +1601,9 @@
if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) { + printf("conversion to GL_BGRA, forced to 4\n"); idx = getFmtIdx(WINED3DFMT_B8G8R8A8_UNORM); - gl_info->formats[idx].gl_vtx_format = GL_BGRA; + gl_info->formats[idx].gl_vtx_format = 4; }
if (gl_info->supported[ARB_HALF_FLOAT_VERTEX]) -----------------------------------------------------------
Works the same, with the swap between R and B component. I'm surprised, because the debug (printf("conversion to GL_BGRA, forced to 4\n") is only called a few time. Does that mean that this part of the code is only called when declaring *vertex stream* (ie: VAO ?).
I propose the following changes:
a) in device.c, removes the test which fallbacks to drawPrimitiveSlow if ARB_VERTEX_ARRAY_BGRA is not available b) somewhere just before the glColorPointer call, convert the array with a simple loop
I have a prototype of this code running, I still need to find an elegant solution for the place to store the data because I think I cannot do the conversion in place. More later, I need to go to work.
Personally though, I think it's probably more productive to work on fixing any issues in Mesa / Nouveau for your hardware, and just use those drivers instead.
I'm using the Nvidia driver. Your answer makes me give the nouveau driver a chance, but it segfault when launching WoW. (Amazingly enough, it have the ARB_vertex_array_bgra extension available. Also blender starts to work with it, which was not the case last time I tried, so it may be worth looking)
Thank you for your comments