From: Kristian Høgsberg Kristensen Date: Fri, 29 May 2015 23:06:06 +0000 (-0700) Subject: vk: Implement support for sampler border colors X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dc56e4f7b88ab79be12632fbf032ef85fd32f602;p=mesa.git vk: Implement support for sampler border colors 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. --- diff --git a/src/vulkan/device.c b/src/vulkan/device.c index f0e73b3687a..1622bb8853e 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -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, diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 4b7c84262d3..25f8a230398 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -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;