r600g: Add support for GL_ARB_texture_buffer_range
authorFredrik Höglund <fredrik@kde.org>
Fri, 22 Mar 2013 16:14:43 +0000 (17:14 +0100)
committerFredrik Höglund <fredrik@kde.org>
Wed, 10 Apr 2013 22:10:45 +0000 (00:10 +0200)
Reviewed-by: Marek Olšák <maraeo@gmail.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_state.c

index 7169614143a054b2b91864ba6a1cbd39f2b06e2e..86f141182416cc6a909a75ea80341a2b82d18cca 100644 (file)
@@ -1047,6 +1047,8 @@ texture_buffer_sampler_view(struct r600_pipe_sampler_view *view,
        unsigned swizzle_res;
        unsigned char swizzle[4];
        const struct util_format_description *desc;
+       unsigned offset = view->base.u.buf.first_element * stride;
+       unsigned size = (view->base.u.buf.last_element - view->base.u.buf.first_element + 1) * stride;
 
        swizzle[0] = view->base.swizzle_r;
        swizzle[1] = view->base.swizzle_g;
@@ -1061,12 +1063,12 @@ texture_buffer_sampler_view(struct r600_pipe_sampler_view *view,
 
        swizzle_res = r600_get_swizzle_combined(desc->swizzle, swizzle, TRUE);
 
-       va = r600_resource_va(ctx->screen, view->base.texture);
+       va = r600_resource_va(ctx->screen, view->base.texture) + offset;
        view->tex_resource = &tmp->resource;
 
        view->skip_mip_address_reloc = true;
        view->tex_resource_words[0] = va;
-       view->tex_resource_words[1] = width0 - 1;
+       view->tex_resource_words[1] = size - 1;
        view->tex_resource_words[2] = S_030008_BASE_ADDRESS_HI(va >> 32UL) |
                S_030008_STRIDE(stride) |
                S_030008_DATA_FORMAT(format) |
index 7f308f7d001e058bee4dba9622450a3c789c25ff..ec83c45c83e4e4ae19c12b683f719398d0e791c7 100644 (file)
@@ -575,6 +575,9 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
                return 256;
 
+       case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
+               return 1;
+
        case PIPE_CAP_GLSL_FEATURE_LEVEL:
                return 140;
 
@@ -601,7 +604,6 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
        case PIPE_CAP_VERTEX_COLOR_CLAMPED:
        case PIPE_CAP_USER_VERTEX_BUFFERS:
-       case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
        case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
                return 0;
 
index c6d98bbccf60136917364d3eddd61e559b1b7f6d..a7e69238bbe563d263f9e85f33cccd7a61e28324 100644 (file)
@@ -1027,17 +1027,19 @@ texture_buffer_sampler_view(struct r600_pipe_sampler_view *view,
        uint64_t va;
        int stride = util_format_get_blocksize(view->base.format);
        unsigned format, num_format, format_comp, endian;
+       unsigned offset = view->base.u.buf.first_element * stride;
+       unsigned size = (view->base.u.buf.last_element - view->base.u.buf.first_element + 1) * stride;
 
        r600_vertex_data_type(view->base.format,
                              &format, &num_format, &format_comp,
                              &endian);
 
-       va = r600_resource_va(ctx->screen, view->base.texture);
+       va = r600_resource_va(ctx->screen, view->base.texture) + offset;
        view->tex_resource = &tmp->resource;
 
        view->skip_mip_address_reloc = true;
        view->tex_resource_words[0] = va;
-       view->tex_resource_words[1] = width0 - 1;
+       view->tex_resource_words[1] = size - 1;
        view->tex_resource_words[2] = S_038008_BASE_ADDRESS_HI(va >> 32UL) |
                S_038008_STRIDE(stride) |
                S_038008_DATA_FORMAT(format) |