isl: Add a swizzle parameter to isl_buffer_fill_state()
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 28 Feb 2019 09:13:33 +0000 (01:13 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 7 Mar 2019 19:39:27 +0000 (11:39 -0800)
This is necessary for legacy texture buffer object formats, where we'll
need to use a swizzle to fake e.g. luminance.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/gallium/drivers/iris/iris_state.c
src/intel/isl/isl.h
src/intel/isl/isl_surface_state.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_image.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c

index ec39225716c305cf4551ddef4840bda068ea5520..592b2c48ade53b9c60a057cc9be0299c8d547b13 100644 (file)
@@ -1560,6 +1560,7 @@ fill_buffer_surface_state(struct isl_device *isl_dev,
                          .address = bo->gtt_offset + offset,
                          .size_B = final_size,
                          .format = format,
+                         .swizzle = ISL_SWIZZLE_IDENTITY,
                          .stride_B = cpp,
                          .mocs = mocs(bo));
 }
@@ -2352,6 +2353,7 @@ upload_ubo_surf_state(struct iris_context *ice,
                          .size_B = MIN2(buffer_size,
                                         res->bo->size - cbuf->data.offset),
                          .format = ISL_FORMAT_R32G32B32A32_FLOAT,
+                         .swizzle = ISL_SWIZZLE_IDENTITY,
                          .stride_B = 1,
                          .mocs = mocs(res->bo))
 }
@@ -2509,6 +2511,7 @@ iris_set_shader_buffers(struct pipe_context *ctx,
                                   MIN2(buffer->buffer_size,
                                        res->bo->size - buffer->buffer_offset),
                                .format = ISL_FORMAT_RAW,
+                               .swizzle = ISL_SWIZZLE_IDENTITY,
                                .stride_B = 1,
                                .mocs = mocs(res->bo));
       } else {
index cfac922a3d2b695bfca62b20c151b3f12c08d11c..a792e18e5d1420923efa677cd079f74bdbe0d741 100644 (file)
@@ -1361,6 +1361,11 @@ struct isl_buffer_fill_state_info {
     */
    enum isl_format format;
 
+   /**
+    * The swizzle to use in the surface state
+    */
+   struct isl_swizzle swizzle;
+
    uint32_t stride_B;
 };
 
index 7ab260d701b294393243895d35a106edc7621d45..cf31b36ccbe1e2d748ccfc4443b272eb78f05ef2 100644 (file)
@@ -745,10 +745,10 @@ isl_genX(buffer_fill_state_s)(void *state,
 #endif
 
 #if (GEN_GEN >= 8 || GEN_IS_HASWELL)
-   s.ShaderChannelSelectRed = SCS_RED;
-   s.ShaderChannelSelectGreen = SCS_GREEN;
-   s.ShaderChannelSelectBlue = SCS_BLUE;
-   s.ShaderChannelSelectAlpha = SCS_ALPHA;
+   s.ShaderChannelSelectRed = (enum GENX(ShaderChannelSelect)) info->swizzle.r;
+   s.ShaderChannelSelectGreen = (enum GENX(ShaderChannelSelect)) info->swizzle.g;
+   s.ShaderChannelSelectBlue = (enum GENX(ShaderChannelSelect)) info->swizzle.b;
+   s.ShaderChannelSelectAlpha = (enum GENX(ShaderChannelSelect)) info->swizzle.a;
 #endif
 
    GENX(RENDER_SURFACE_STATE_pack)(NULL, state, &s);
index 92e8f40278f545d6ad7922afe12a6ffd342830ea..963f108a0e843bd71c3dd8318afcc0fbf04a8fb5 100644 (file)
@@ -3324,6 +3324,7 @@ anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
                          .mocs = device->default_mocs,
                          .size_B = range,
                          .format = format,
+                         .swizzle = ISL_SWIZZLE_IDENTITY,
                          .stride_B = stride);
 }
 
index facf7d18006a4201822af66a61b5ed0b8be56911..dfa72cbfe6c62a516bb0a703ffc9b1d60a8d1b1f 100644 (file)
@@ -1203,6 +1203,7 @@ anv_image_fill_surface_state(struct anv_device *device,
                             .address = anv_address_physical(address),
                             .size_B = surface->isl.size_B,
                             .format = ISL_FORMAT_RAW,
+                            .swizzle = ISL_SWIZZLE_IDENTITY,
                             .stride_B = 1,
                             .mocs = anv_mocs_for_bo(device, address.bo));
       state_inout->address = address,
index a09847916149a5bb3248468401a92440b2427301..8175fbf0db49356dc7ca086f9595e0be11108655 100644 (file)
@@ -647,6 +647,7 @@ brw_emit_buffer_surface_state(struct brw_context *brw,
                                                     reloc_flags),
                          .size_B = buffer_size,
                          .format = surface_format,
+                         .swizzle = ISL_SWIZZLE_IDENTITY,
                          .stride_B = pitch,
                          .mocs = brw_get_bo_mocs(devinfo, bo));
 }