freedreno/a3xx: allow num_samplers != num_textures
authorRob Clark <robclark@freedesktop.org>
Fri, 1 Nov 2013 14:09:39 +0000 (10:09 -0400)
committerRob Clark <robclark@freedesktop.org>
Sat, 2 Nov 2013 00:20:29 +0000 (20:20 -0400)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_emit.c
src/gallium/drivers/freedreno/a3xx/fd3_util.c

index 47c57133965c59d168dc068412d4993309f513c5..b1c0e74a2ee20abeff4cd2339dde0f1c1b9054d6 100644 (file)
@@ -163,65 +163,64 @@ emit_textures(struct fd_ringbuffer *ring,
        };
        unsigned i, j;
 
-       assert(tex->num_samplers == tex->num_textures);  // TODO check..
-
-       if (!tex->num_samplers)
-               return;
-
-       /* output sampler state: */
-       OUT_PKT3(ring, CP_LOAD_STATE, 2 + (2 * tex->num_samplers));
-       OUT_RING(ring, CP_LOAD_STATE_0_DST_OFF(tex_off[sb]) |
-                       CP_LOAD_STATE_0_STATE_SRC(SS_DIRECT) |
-                       CP_LOAD_STATE_0_STATE_BLOCK(sb) |
-                       CP_LOAD_STATE_0_NUM_UNIT(tex->num_samplers));
-       OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_SHADER) |
-                       CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
-       for (i = 0; i < tex->num_samplers; i++) {
-               struct fd3_sampler_stateobj *sampler =
-                               fd3_sampler_stateobj(tex->samplers[i]);
-               OUT_RING(ring, sampler->texsamp0);
-               OUT_RING(ring, sampler->texsamp1);
-       }
-
-       /* emit texture state: */
-       OUT_PKT3(ring, CP_LOAD_STATE, 2 + (4 * tex->num_textures));
-       OUT_RING(ring, CP_LOAD_STATE_0_DST_OFF(tex_off[sb]) |
-                       CP_LOAD_STATE_0_STATE_SRC(SS_DIRECT) |
-                       CP_LOAD_STATE_0_STATE_BLOCK(sb) |
-                       CP_LOAD_STATE_0_NUM_UNIT(tex->num_textures));
-       OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
-                       CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
-       for (i = 0; i < tex->num_textures; i++) {
-               struct fd3_pipe_sampler_view *view =
-                               fd3_pipe_sampler_view(tex->textures[i]);
-               OUT_RING(ring, view->texconst0);
-               OUT_RING(ring, view->texconst1);
-               OUT_RING(ring, view->texconst2 |
-                               A3XX_TEX_CONST_2_INDX(BASETABLE_SZ * i));
-               OUT_RING(ring, view->texconst3);
+       if (tex->num_samplers > 0) {
+               /* output sampler state: */
+               OUT_PKT3(ring, CP_LOAD_STATE, 2 + (2 * tex->num_samplers));
+               OUT_RING(ring, CP_LOAD_STATE_0_DST_OFF(tex_off[sb]) |
+                               CP_LOAD_STATE_0_STATE_SRC(SS_DIRECT) |
+                               CP_LOAD_STATE_0_STATE_BLOCK(sb) |
+                               CP_LOAD_STATE_0_NUM_UNIT(tex->num_samplers));
+               OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_SHADER) |
+                               CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
+               for (i = 0; i < tex->num_samplers; i++) {
+                       struct fd3_sampler_stateobj *sampler =
+                                       fd3_sampler_stateobj(tex->samplers[i]);
+                       OUT_RING(ring, sampler->texsamp0);
+                       OUT_RING(ring, sampler->texsamp1);
+               }
        }
 
-       /* emit mipaddrs: */
-       OUT_PKT3(ring, CP_LOAD_STATE, 2 + (BASETABLE_SZ * tex->num_textures));
-       OUT_RING(ring, CP_LOAD_STATE_0_DST_OFF(BASETABLE_SZ * tex_off[sb]) |
-                       CP_LOAD_STATE_0_STATE_SRC(SS_DIRECT) |
-                       CP_LOAD_STATE_0_STATE_BLOCK(mipaddr[sb]) |
-                       CP_LOAD_STATE_0_NUM_UNIT(BASETABLE_SZ * tex->num_textures));
-       OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
-                       CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
-       for (i = 0; i < tex->num_textures; i++) {
-               struct fd3_pipe_sampler_view *view =
-                               fd3_pipe_sampler_view(tex->textures[i]);
-               struct fd_resource *rsc = view->tex_resource;
-
-               for (j = 0; j < view->mipaddrs; j++) {
-                       struct fd_resource_slice *slice = fd_resource_slice(rsc, j);
-                       OUT_RELOC(ring, rsc->bo, slice->offset, 0, 0);
+       if (tex->num_textures > 0) {
+               /* emit texture state: */
+               OUT_PKT3(ring, CP_LOAD_STATE, 2 + (4 * tex->num_textures));
+               OUT_RING(ring, CP_LOAD_STATE_0_DST_OFF(tex_off[sb]) |
+                               CP_LOAD_STATE_0_STATE_SRC(SS_DIRECT) |
+                               CP_LOAD_STATE_0_STATE_BLOCK(sb) |
+                               CP_LOAD_STATE_0_NUM_UNIT(tex->num_textures));
+               OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
+                               CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
+               for (i = 0; i < tex->num_textures; i++) {
+                       struct fd3_pipe_sampler_view *view =
+                                       fd3_pipe_sampler_view(tex->textures[i]);
+                       OUT_RING(ring, view->texconst0);
+                       OUT_RING(ring, view->texconst1);
+                       OUT_RING(ring, view->texconst2 |
+                                       A3XX_TEX_CONST_2_INDX(BASETABLE_SZ * i));
+                       OUT_RING(ring, view->texconst3);
                }
 
-               /* pad the remaining entries w/ null: */
-               for (; j < BASETABLE_SZ; j++) {
-                       OUT_RING(ring, 0x00000000);
+               /* emit mipaddrs: */
+               OUT_PKT3(ring, CP_LOAD_STATE, 2 + (BASETABLE_SZ * tex->num_textures));
+               OUT_RING(ring, CP_LOAD_STATE_0_DST_OFF(BASETABLE_SZ * tex_off[sb]) |
+                               CP_LOAD_STATE_0_STATE_SRC(SS_DIRECT) |
+                               CP_LOAD_STATE_0_STATE_BLOCK(mipaddr[sb]) |
+                               CP_LOAD_STATE_0_NUM_UNIT(BASETABLE_SZ * tex->num_textures));
+               OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
+                               CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
+               for (i = 0; i < tex->num_textures; i++) {
+                       struct fd3_pipe_sampler_view *view =
+                                       fd3_pipe_sampler_view(tex->textures[i]);
+                       struct fd_resource *rsc = view->tex_resource;
+
+                       for (j = 0; j < view->mipaddrs; j++) {
+                               struct fd_resource_slice *slice = fd_resource_slice(rsc, j);
+                               OUT_RELOC(ring, rsc->bo, slice->offset, 0, 0);
+                       }
+
+                       /* pad the remaining entries w/ null: */
+                       for (; j < BASETABLE_SZ; j++) {
+                               OUT_RING(ring, 0x00000000);
+                       }
                }
        }
 }
index 21ef43434f9eb36f02a3769d4cc3cb4e558c9933..7503dfefa31b75cae63e30a5f80743369714835e 100644 (file)
@@ -267,7 +267,7 @@ fd3_pipe2fetchsize(enum pipe_format format)
        // TODO add more..
 
        default:
-               return TFETCH_DISABLE;  /* save default */
+               return TFETCH_DISABLE;  /* safe default */
        }
 }