gen8: Fix border color
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 18 Jan 2016 20:16:31 +0000 (12:16 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 18 Jan 2016 20:16:31 +0000 (12:16 -0800)
The border color packet is specified as a 64-byte aligned address relative
to dynamic state base address.  The way the packing functions are currently
set up, we need to provide it with (offset >> 6) because it just shoves the
bits in where the PRM says they go and isn't really aware that it's an
address.

src/vulkan/anv_device.c
src/vulkan/gen8_state.c

index c7e70412eb8730720cd3e006baa0237cd205c16f..7493ff7b7fc59c4cacd31d0c790b851ca31113ce 100644 (file)
@@ -643,10 +643,19 @@ anv_state_pool_emit_data(struct anv_state_pool *pool, size_t size, size_t align,
    return state;
 }
 
+struct gen8_border_color {
+   union {
+      float float32[4];
+      uint32_t uint32[4];
+   };
+   /* Pad out to 64 bytes */
+   uint32_t _pad[12];
+};
+
 static void
 anv_device_init_border_colors(struct anv_device *device)
 {
-   static const VkClearColorValue border_colors[] = {
+   static const struct gen8_border_color border_colors[] = {
       [VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK] =  { .float32 = { 0.0, 0.0, 0.0, 0.0 } },
       [VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK] =       { .float32 = { 0.0, 0.0, 0.0, 1.0 } },
       [VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE] =       { .float32 = { 1.0, 1.0, 1.0, 1.0 } },
@@ -656,7 +665,8 @@ anv_device_init_border_colors(struct anv_device *device)
    };
 
    device->border_colors = anv_state_pool_emit_data(&device->dynamic_state_pool,
-                                                    sizeof(border_colors), 32, border_colors);
+                                                    sizeof(border_colors), 64,
+                                                    border_colors);
 }
 
 VkResult anv_CreateDevice(
index 9fa2a0554b91015494430be03025812fb8b381e9..53a75ef5fb6723020fd5a0b4ca0baa92514a9f0d 100644 (file)
@@ -380,6 +380,9 @@ VkResult genX(CreateSampler)(
    uint32_t filter = vk_to_gen_tex_filter(pCreateInfo->magFilter,
                                           pCreateInfo->anisotropyEnable);
 
+   uint32_t border_color_offset = device->border_colors.offset +
+                                  pCreateInfo->borderColor * 64;
+
    struct GENX(SAMPLER_STATE) sampler_state = {
       .SamplerDisable = false,
       .TextureBorderColorMode = DX10OGL,
@@ -400,9 +403,7 @@ VkResult genX(CreateSampler)(
       .ShadowFunction = vk_to_gen_compare_op[pCreateInfo->compareOp],
       .CubeSurfaceControlMode = 0,
 
-      .IndirectStatePointer =
-         device->border_colors.offset +
-         pCreateInfo->borderColor * sizeof(float) * 4,
+      .IndirectStatePointer = border_color_offset >> 6,
 
       .LODClampMagnificationMode = MIPNONE,
       .MaximumAnisotropy = vk_to_gen_max_anisotropy(pCreateInfo->maxAnisotropy),