[PATCH] wined3d: Don't accept WINED3DFMT_NULL

Max Qian contrib at maxqia.com
Sun May 22 02:19:06 CDT 2016


On 2016-05-21 9:17 am, Stefan Dösinger wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> 
> 
> Hi,
> 
> Thanks for catching this bug. You'll have to submit your patch with
> your real name, and as Aaryaman stated, a signed off line.
> 
> Am 2016-05-21 um 10:46 schrieb contrib at maxqia.com:
>> -    if (!surface)
>> +    if (!surface || surface->container->resource.format->id == 
>> WINED3DFMT_NULL)
>>      {
>>          key->objects[idx].object = 0;
>>          key->objects[idx].target = 0;
> My sense is that a D3DFMT_NULL texture should hever have a GL texture
> allocated, so going through the final else path should be ok -
> surface_get_texture_name returns 0, and context_attach_surface_fbo
> ignores the other fields if object is 0. Can you check if object is !=
> 0 in the case where it fails, and see where the value comes from? I
> can imagine that the game manually calls PreLoad on a NULL texture as
> a possible cause. In our draw and clear code we're skipping the GL
> texture allocation for NULL resources.
> 
> If the GL texture is not 0 I expect that you get a GL error before
> context_set_fbo_key_for_surface is run. If it is indeed 0 and
> something goes wrong at a later point then my reasoning above must be
> wrong in some way.
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
> 
> iQIcBAEBCAAGBQJXQG4IAAoJEN0/YqbEcdMwQOQP/20p3/P+Ej25ABqMh83F9l1/
> OlhCUM3BdjYxYaZacopDInmudVALgTLaQe28dlKMw181XSqQ1op9acwHXSvXkNKM
> ZyvNIsqtLxenX37ZWu0I22xqV+DFU07D4TbzrQMAlgMd9XUK2713PhNVKRuYSLpS
> LazcTMldRoiHOxrJF7spbAr0Nn2JPGwHV/4NA0baQdIycnVQqztFQHPmdRVSP/eO
> 9zOacv0AKDaPt3GXgJV0+S7QuDW9EEsXI6nkytDJpazBnfSrJRCVQIGhPiokf9ik
> dlFkwYKuZe/fSTgSfyxyB0IhQoaOsfM4LTSJymQpneADRLhbmPORORMdzFMW/GrN
> qKPgK28U2oES3u3YF6u5/2YgfrSUvJvvqPe8077Tyl60uG5W7lBWeMQ4HUDaDHgW
> vWcDbvX1vYh+BG5zIvvVzGvmRKoKYnnEj65iqGqpi/vcJMz2f4ff/vmAiT1y23Hl
> 0Y50ZUxTWXpUVi4uzoQlKgpmXbny2je0P2K12zbA13J3kJ/LxoHqefm1RW9VJ1w4
> VxYD94lbk4zchO0AQwbLK83b7f8QoTZH2quqyzbgyFoAynXv0RDhQ2ZjtRN66Jh+
> HmFOprGcCEmOnFs9c0JS8c9MSBVc8g1i6XmnnnccO3wyaw7vrNQbNmnqPRhkpPEV
> ELMYspnFGK8apZ7633Dq
> =QeKV
> -----END PGP SIGNATURE-----

It seems like surface_get_texture_name isn't returning 0.

Code Added :
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e741969..27f1d04 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -424,6 +424,12 @@ static inline void 
context_set_fbo_key_for_surface(const struct wined3d_context
                  break;
          }
      }
+    if (key->objects[idx].object != 0 && 
surface->container->resource.format->id == WINED3DFMT_NULL)
+        ERR("WINED3DFMT_NULL object is %i at %x\n", 
key->objects[idx].object, location);
+    if (key->objects[idx].target != 0 && 
surface->container->resource.format->id == WINED3DFMT_NULL)
+        ERR("WINED3DFMT_NULL target is %i at %x\n", 
key->objects[idx].target, location);
+    if (key->objects[idx].level != 0 && 
surface->container->resource.format->id == WINED3DFMT_NULL)
+        ERR("WINED3DFMT_NULL level is %i at %x\n", 
key->objects[idx].level, location);
  }

  static void context_generate_fbo_key(const struct wined3d_context 
*context,

Snippet from Console : (10 is WINED3D_LOCATION_TEXTURE_RGB)
err:d3d:context_set_fbo_key_for_surface WINED3DFMT_NULL object is 105 at 
10
err:d3d:context_set_fbo_key_for_surface WINED3DFMT_NULL target is 3553 
at 10
err:d3d:context_set_fbo_key_for_surface WINED3DFMT_NULL object is 105 at 
10
err:d3d:context_set_fbo_key_for_surface WINED3DFMT_NULL target is 3553 
at 10
fixme:d3d:context_check_fbo_status FBO status 
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT (0x8cd6)
fixme:d3d:context_dump_fbo_attachment     GL_DEPTH_ATTACHMENT: 2d 
texture 104, 2048x2048, format 0x81a6.
fixme:d3d:context_dump_fbo_attachment     GL_STENCIL_ATTACHMENT: NONE.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT0: 2d 
texture 105, 0x0, format 0x1.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT1: NONE.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT2: NONE.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT3: NONE.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT4: NONE.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT5: NONE.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT6: NONE.
fixme:d3d:context_dump_fbo_attachment     GL_COLOR_ATTACHMENT7: NONE.
err:d3d:wined3d_debug_callback 0x1dd038: 
"GL_INVALID_FRAMEBUFFER_OPERATION error generated. Operation is not 
valid because a bound framebuffer is not framebuffer complete.".
err:d3d:device_clear_render_targets >>>>>>>>>>>>>>>>> 
GL_INVALID_FRAMEBUFFER_OPERATION (0x506) from glClear @ 
../../../source/dlls/wined3d/device.c / 509



More information about the wine-devel mailing list