From d49298c702e6cd1ca7ac77396bd6dd377ed9b635 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 18 Jan 2016 12:16:31 -0800 Subject: [PATCH] gen8: Fix border color 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 | 14 ++++++++++++-- src/vulkan/gen8_state.c | 7 ++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index c7e70412eb8..7493ff7b7fc 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -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( diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index 9fa2a0554b9..53a75ef5fb6 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -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), -- 2.30.2