r600g: enable vertex samplers.
authorDave Airlie <airlied@redhat.com>
Mon, 11 Oct 2010 01:58:27 +0000 (11:58 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 11 Oct 2010 01:59:53 +0000 (11:59 +1000)
We need to move the texture sampler resources out of the range of the vertex attribs.

We could probably improve this using an allocator but this is the simple answer for now.

makes mesa-demos/src/glsl/vert-tex work.

src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_state.c

index bdd54811fb2ce12a64c094c2a4dff091f4701f43..323509f6402e108d1fc8b36bf27d60f5f7428c49 100644 (file)
@@ -480,8 +480,14 @@ static struct pipe_sampler_view *evergreen_create_sampler_view(struct pipe_conte
 static void evergreen_set_vs_sampler_view(struct pipe_context *ctx, unsigned count,
                                        struct pipe_sampler_view **views)
 {
-       /* TODO */
-       assert(1);
+       struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
+       struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
+
+       for (int i = 0; i < count; i++) {
+               if (resource[i]) {
+                       evergreen_context_pipe_state_set_vs_resource(&rctx->ctx, &resource[i]->state, i + PIPE_MAX_ATTRIBS);
+               }
+       }
 }
 
 static void evergreen_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
@@ -523,7 +529,6 @@ static void evergreen_bind_vs_sampler(struct pipe_context *ctx, unsigned count,
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state **rstates = (struct r600_pipe_state **)states;
 
-       /* TODO implement */
        for (int i = 0; i < count; i++) {
                evergreen_context_pipe_state_set_vs_sampler(&rctx->ctx, rstates[i], i);
        }
index 0589652f7058514966095af2cba5d7a2573fc12c..832a2b2b606b9879c85c66e6f5c371391ae058a6 100644 (file)
@@ -257,7 +257,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
                return 14;
        case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
                /* FIXME allow this once infrastructure is there */
-               return 0;
+               return 16;
        case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
        case PIPE_CAP_MAX_COMBINED_SAMPLERS:
                return 16;
index 366d5d9c351c39587be2b9efa7b4b9cddd1da343..d22325e8b78b7737505b353bd6961496917b9e2e 100644 (file)
@@ -1866,8 +1866,10 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
 
        memset(&tex, 0, sizeof(struct r600_bc_tex));
        tex.inst = opcode;
-       tex.resource_id = ctx->file_offset[inst->Src[1].Register.File] + inst->Src[1].Register.Index;
-       tex.sampler_id = tex.resource_id;
+       tex.sampler_id = ctx->file_offset[inst->Src[1].Register.File] + inst->Src[1].Register.Index;
+       tex.resource_id = tex.sampler_id;
+       if (ctx->shader->processor_type == TGSI_PROCESSOR_VERTEX)
+               tex.resource_id += PIPE_MAX_ATTRIBS;
        tex.src_gpr = src_gpr;
        tex.dst_gpr = ctx->file_offset[inst->Dst[0].Register.File] + inst->Dst[0].Register.Index;
        tex.dst_sel_x = (inst->Dst[0].Register.WriteMask & 1) ? 0 : 7;
index 7ceedf6363b01ef8eee3c9545f76d0d2b4c7e320..29d9d154a2416c75e18f199d53fc3f2982e9bb7b 100644 (file)
@@ -683,8 +683,14 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
 static void r600_set_vs_sampler_view(struct pipe_context *ctx, unsigned count,
                                        struct pipe_sampler_view **views)
 {
-       /* TODO */
-       assert(1);
+       struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
+       struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
+
+       for (int i = 0; i < count; i++) {
+               if (resource[i]) {
+                       r600_context_pipe_state_set_ps_resource(&rctx->ctx, &resource[i]->state, i + PIPE_MAX_ATTRIBS);
+               }
+       }
 }
 
 static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
@@ -726,7 +732,6 @@ static void r600_bind_vs_sampler(struct pipe_context *ctx, unsigned count, void
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state **rstates = (struct r600_pipe_state **)states;
 
-       /* TODO implement */
        for (int i = 0; i < count; i++) {
                r600_context_pipe_state_set_vs_sampler(&rctx->ctx, rstates[i], i);
        }