vk: Implement support for sampler border colors
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 29 May 2015 23:06:06 +0000 (16:06 -0700)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Mon, 1 Jun 2015 00:20:48 +0000 (17:20 -0700)
This supports the three Vulkan border color types for float color
formats. The support for integer formats is a little trickier, as we
don't know the format of the texture at this time.

src/vulkan/device.c
src/vulkan/private.h

index f0e73b3687a155fddbcde322fa14ee855763cd61..1622bb8853e7c283380e4b7d4f91de3217da4de5 100644 (file)
@@ -303,6 +303,35 @@ parse_debug_flags(struct anv_device *device)
    }
 }
 
+static void
+anv_device_init_border_colors(struct anv_device *device)
+{
+   float float_border_colors[][4] = {
+      [VK_BORDER_COLOR_OPAQUE_WHITE]            = { 1.0, 1.0, 1.0, 1.0 },
+      [VK_BORDER_COLOR_TRANSPARENT_BLACK]       = { 0.0, 0.0, 0.0, 0.0 },
+      [VK_BORDER_COLOR_OPAQUE_BLACK]            = { 0.0, 0.0, 0.0, 1.0 }
+   };
+
+   uint32_t uint32_border_colors[][4] = {
+      [VK_BORDER_COLOR_OPAQUE_WHITE]            = { 1, 1, 1, 1 },
+      [VK_BORDER_COLOR_TRANSPARENT_BLACK]       = { 0, 0, 0, 0 },
+      [VK_BORDER_COLOR_OPAQUE_BLACK]            = { 0, 0, 0, 1 }
+   };
+
+   device->float_border_colors =
+      anv_state_pool_alloc(&device->dynamic_state_pool,
+                           sizeof(float_border_colors), 32);
+   memcpy(device->float_border_colors.map,
+          float_border_colors, sizeof(float_border_colors));
+
+   device->uint32_border_colors =
+      anv_state_pool_alloc(&device->dynamic_state_pool,
+                           sizeof(uint32_border_colors), 32);
+   memcpy(device->uint32_border_colors.map,
+          uint32_border_colors, sizeof(uint32_border_colors));
+
+}
+
 static const uint32_t BATCH_SIZE = 8192;
 
 VkResult anv_CreateDevice(
@@ -366,6 +395,8 @@ VkResult anv_CreateDevice(
 
    anv_device_init_meta(device);
 
+   anv_device_init_border_colors(device);
+
    *pDevice = (VkDevice) device;
 
    return VK_SUCCESS;
@@ -1715,7 +1746,11 @@ VkResult anv_CreateSampler(
       .ChromaKeyMode = 0,
       .ShadowFunction = vk_to_gen_compare_op[pCreateInfo->compareOp],
       .CubeSurfaceControlMode = 0,
-      .IndirectStatePointer = 0,
+
+      .IndirectStatePointer =
+         device->float_border_colors.offset +
+         pCreateInfo->borderColor * sizeof(float) * 4;
+
       .LODClampMagnificationMode = MIPNONE,
       .MaximumAnisotropy = 0,
       .RAddressMinFilterRoundingEnable = 0,
index 4b7c84262d313852844edb3282b9cbcb1bd17721..25f8a2303988ec00a3cd6a2022d4a20e13d6f289 100644 (file)
@@ -336,6 +336,9 @@ struct anv_device {
 
     struct anv_meta_state                       meta_state;
 
+    struct anv_state                            float_border_colors;
+    struct anv_state                            uint32_border_colors;
+
     struct anv_compiler *                       compiler;
     struct anv_aub_writer *                     aub_writer;
     pthread_mutex_t                             mutex;