From: Jason Ekstrand Date: Wed, 8 Jul 2015 18:44:52 +0000 (-0700) Subject: vk/vulkan.h: Move over to the new border color enums X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=522ab835d6f14da3d6f08ed0bbd81573fcee1b25;p=mesa.git vk/vulkan.h: Move over to the new border color enums --- diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index 3ff56aae5ea..14d4bd52706 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -732,12 +732,15 @@ typedef enum { } VkTexAddress; typedef enum { - VK_BORDER_COLOR_OPAQUE_WHITE = 0, - VK_BORDER_COLOR_TRANSPARENT_BLACK = 1, - VK_BORDER_COLOR_OPAQUE_BLACK = 2, - VK_BORDER_COLOR_BEGIN_RANGE = VK_BORDER_COLOR_OPAQUE_WHITE, - VK_BORDER_COLOR_END_RANGE = VK_BORDER_COLOR_OPAQUE_BLACK, - VK_BORDER_COLOR_NUM = (VK_BORDER_COLOR_OPAQUE_BLACK - VK_BORDER_COLOR_OPAQUE_WHITE + 1), + VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0, + VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1, + VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2, + VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3, + VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4, + VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5, + VK_BORDER_COLOR_BEGIN_RANGE = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, + VK_BORDER_COLOR_END_RANGE = VK_BORDER_COLOR_INT_OPAQUE_WHITE, + VK_BORDER_COLOR_NUM = (VK_BORDER_COLOR_INT_OPAQUE_WHITE - VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK + 1), VK_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF } VkBorderColor; diff --git a/src/vulkan/device.c b/src/vulkan/device.c index ce12c0defa8..4040745c25a 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -338,30 +338,19 @@ anv_queue_finish(struct anv_queue *queue) 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 } + static const VkClearColorValue border_colors[] = { + [VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK] = { .f32 = { 0.0, 0.0, 0.0, 0.0 } }, + [VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK] = { .f32 = { 0.0, 0.0, 0.0, 1.0 } }, + [VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE] = { .f32 = { 1.0, 1.0, 1.0, 1.0 } }, + [VK_BORDER_COLOR_INT_TRANSPARENT_BLACK] = { .u32 = { 0, 0, 0, 0 } }, + [VK_BORDER_COLOR_INT_OPAQUE_BLACK] = { .u32 = { 0, 0, 0, 1 } }, + [VK_BORDER_COLOR_INT_OPAQUE_WHITE] = { .u32 = { 1, 1, 1, 1 } }, }; - 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 = + device->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)); - + sizeof(border_colors), 32); + memcpy(device->border_colors.map, border_colors, sizeof(border_colors)); } static const uint32_t BATCH_SIZE = 8192; @@ -451,10 +440,7 @@ VkResult anv_DestroyDevice( /* We only need to free these to prevent valgrind errors. The backing * BO will go away in a couple of lines so we don't actually leak. */ - anv_state_pool_free(&device->dynamic_state_pool, - device->float_border_colors); - anv_state_pool_free(&device->dynamic_state_pool, - device->uint32_border_colors); + anv_state_pool_free(&device->dynamic_state_pool, device->border_colors); #endif anv_bo_pool_finish(&device->batch_bo_pool); @@ -1537,7 +1523,7 @@ VkResult anv_CreateSampler( .CubeSurfaceControlMode = 0, .IndirectStatePointer = - device->float_border_colors.offset + + device->border_colors.offset + pCreateInfo->borderColor * sizeof(float) * 4, .LODClampMagnificationMode = MIPNONE, diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 77de59340cf..4eb3a953173 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -412,8 +412,7 @@ struct anv_device { struct anv_meta_state meta_state; - struct anv_state float_border_colors; - struct anv_state uint32_border_colors; + struct anv_state border_colors; struct anv_queue queue;