[Mesa-dev] [Mesa-stable] [PATCH] st/mesa: use first image's dimensions when finalizing texture

Brian Paul brianp at vmware.com
Mon Jun 6 16:52:42 UTC 2016


On 06/06/2016 10:05 AM, Ilia Mirkin wrote:
> On Mon, Jun 6, 2016 at 11:37 AM, Brian Paul <brianp at vmware.com> wrote:
>> On 06/05/2016 12:24 AM, Ilia Mirkin wrote:
>>>
>>> In the case where we can't guess the base level size, just use the first
>>> image's dims. The width0/height0/depth0 on stObj may not have been set
>>> at this point. Observed in a trace that set up levels 2..9 of a 2d
>>> texture,
>>> and set the base level to 2, with height 1. This made the guess logic
>>> always bail.
>>>
>>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>>> Cc: "12.0" <mesa-stable at lists.freedesktop.org>
>>> ---
>>>    src/mesa/state_tracker/st_cb_texture.c | 6 +++---
>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/mesa/state_tracker/st_cb_texture.c
>>> b/src/mesa/state_tracker/st_cb_texture.c
>>> index d38f24c..1dd1ef6 100644
>>> --- a/src/mesa/state_tracker/st_cb_texture.c
>>> +++ b/src/mesa/state_tracker/st_cb_texture.c
>>> @@ -2463,9 +2463,9 @@ st_finalize_texture(struct gl_context *ctx,
>>>                                     firstImage->base.Depth2,
>>>                                     firstImage->base.Level,
>>>                                     &width, &height, &depth)) {
>>> -         width = stObj->width0;
>>> -         height = stObj->height0;
>>> -         depth = stObj->depth0;
>>> +         width = stObj->width0 = firstImage->base.Width2;
>>> +         height = stObj->height0 = firstImage->base.Height2;
>>> +         depth = stObj->depth0 = firstImage->base.Depth2;
>>>          } else {
>>>             /* The width/height/depth may have been previously reset in
>>>              * guess_and_alloc_texture. */
>>>
>>
>> Does this fix a crash or glitch or something else?
>>
>> The state tracker's texture code is pretty delicate so I'd like to fully
>> understand the change.
>
> Yes, this fixes a trace that was supplied by someone on IRC. The
> situation was that the texture only ever had levels 2..9 (or 10?) set,
> and its base level was set to 2. And each level was Nx1 (but
> GL_TEXTURE_2D). So all the guessing logic always bailed, which means
> that the stObj->width/height/depth were set to 0, which caused asserts
> on the next line. (And I assume it wouldn't have rendered correctly
> either, but it can be hard to tell in a large scene.)
>
>>
>> Maybe we should have a piglit test for this?
>
> I can try to whip something up, not sure when I'll get to it though.
> Definitely not today, and probably not for a few at least.

I whipped up a piglet test.  No assertion with your patch, but still 
incorrect rendering.  The textured quad is drawn black instead of gray. 
  Works w/ NVIDIA driver.

I'm attaching the patch if you want to use it to investigate further.  I 
have to get back to other things.

-Brian


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gl-1.2-texture-base-level-new-test-to-exercise-a-Mes.patch
Type: text/x-patch
Size: 5770 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160606/cef78dbb/attachment.bin>


More information about the mesa-dev mailing list