[Mesa-dev] [RFT PATCH 2/2] nv20: enable ARB_texture_border_clamp support

Ian Romanick idr at freedesktop.org
Tue Jun 27 17:11:59 UTC 2017


On 06/27/2017 02:59 AM, Timothy Arceri wrote:
> Just curious. Can this extension be added to NV04 and NV10? As those are
> the only drivers that don't currently support it.
> 
> I have cards I could test those with, but don't have an NV20.

I just sent out an updated series that I tested on NV20.  Thanks for
reminding me. :)

I *think* NV10 can do this, but the implementation would be... painful.
NV10 (and on) supports texture borders... that extra one pixel of pixels
on each side that's outside the usual [0,1]x[0,1] sampling range.  I
believe this extension could be supported by creating every texture with
a border and filling the border with the GL border color.

> On 09/09/16 10:56, Ilia Mirkin wrote:
> 
>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>>
>> This was tested on a NV25-on-NV34 situation. Should be tested on real
>> hardware
>> since my test environment relies on accurate emulation in the hw.
>>
>>   src/mesa/drivers/dri/nouveau/nv20_context.c   |  1 +
>>   src/mesa/drivers/dri/nouveau/nv20_state_tex.c | 29
>> ++++++++++++++++++++++++++-
>>   2 files changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c
>> b/src/mesa/drivers/dri/nouveau/nv20_context.c
>> index ec638c0..6940b4d 100644
>> --- a/src/mesa/drivers/dri/nouveau/nv20_context.c
>> +++ b/src/mesa/drivers/dri/nouveau/nv20_context.c
>> @@ -456,6 +456,7 @@ nv20_context_create(struct nouveau_screen *screen,
>> gl_api api,
>>       if (!nouveau_context_init(ctx, api, screen, visual, share_ctx))
>>           goto fail;
>>   +    ctx->Extensions.ARB_texture_border_clamp = true;
>>       ctx->Extensions.ARB_texture_env_crossbar = true;
>>       ctx->Extensions.ARB_texture_env_combine = true;
>>       ctx->Extensions.ARB_texture_env_dot3 = true;
>> diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
>> b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
>> index b0a4c9f..ef1799a 100644
>> --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
>> +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
>> @@ -165,7 +165,8 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
>>       struct nouveau_surface *s;
>>       struct gl_texture_image *ti;
>>       const struct gl_sampler_object *sa;
>> -    uint32_t tx_format, tx_filter, tx_wrap, tx_enable;
>> +    uint8_t r, g, b, a;
>> +    uint32_t tx_format, tx_filter, tx_wrap, tx_bcolor, tx_enable;
>>         PUSH_RESET(push, BUFCTX_TEX(i));
>>   @@ -201,6 +202,29 @@ nv20_emit_tex_obj(struct gl_context *ctx, int
>> emit)
>>           | nvgl_filter_mode(sa->MinFilter) << 16
>>           | 2 << 12;
>>   +    r = FLOAT_TO_UBYTE(sa->BorderColor.f[0]);
>> +    g = FLOAT_TO_UBYTE(sa->BorderColor.f[1]);
>> +    b = FLOAT_TO_UBYTE(sa->BorderColor.f[2]);
>> +    a = FLOAT_TO_UBYTE(sa->BorderColor.f[3]);
>> +    switch (ti->_BaseFormat) {
>> +    case GL_LUMINANCE:
>> +        a = 0xff;
>> +        /* fallthrough */
>> +    case GL_LUMINANCE_ALPHA:
>> +        g = b = r;
>> +        break;
>> +    case GL_RGB:
>> +        a = 0xff;
>> +        break;
>> +    case GL_INTENSITY:
>> +        g = b = a = r;
>> +        break;
>> +    case GL_ALPHA:
>> +        r = g = b = 0;
>> +        break;
>> +    }
>> +    tx_bcolor = b << 0 | g << 8 | r << 16 | a << 24;
>> +
>>       tx_enable = NV20_3D_TEX_ENABLE_ENABLE
>>           | log2i(sa->MaxAnisotropy) << 4;
>>   @@ -249,6 +273,9 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
>>       BEGIN_NV04(push, NV20_3D(TEX_FILTER(i)), 1);
>>       PUSH_DATA (push, tx_filter);
>>   +    BEGIN_NV04(push, NV20_3D(TEX_BORDER_COLOR(i)), 1);
>> +    PUSH_DATA (push, tx_bcolor);
>> +
>>       BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
>>       PUSH_DATA (push, tx_enable);
>>   
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list