diff options
-rw-r--r-- | include/vulkan/vulkan.h | 924 | ||||
-rw-r--r-- | src/glsl/nir/spirv.h | 119 | ||||
-rw-r--r-- | src/glsl/nir/spirv_glsl450.h | 83 | ||||
-rw-r--r-- | src/glsl/nir/spirv_glsl450_to_nir.c | 7 | ||||
-rw-r--r-- | src/glsl/nir/spirv_to_nir.c | 28 | ||||
-rw-r--r-- | src/vulkan/Makefile.am | 4 | ||||
-rw-r--r-- | src/vulkan/anv_cmd_buffer.c | 436 | ||||
-rw-r--r-- | src/vulkan/anv_device.c | 503 | ||||
-rw-r--r-- | src/vulkan/anv_formats.c | 69 | ||||
-rw-r--r-- | src/vulkan/anv_image.c | 348 | ||||
-rw-r--r-- | src/vulkan/anv_meta.c | 452 | ||||
-rw-r--r-- | src/vulkan/anv_pipeline.c | 117 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 245 | ||||
-rw-r--r-- | src/vulkan/anv_query.c | 11 | ||||
-rw-r--r-- | src/vulkan/anv_util.c | 35 | ||||
-rw-r--r-- | src/vulkan/anv_wsi_wayland.c | 27 | ||||
-rw-r--r-- | src/vulkan/anv_wsi_x11.c | 40 | ||||
-rw-r--r-- | src/vulkan/gen7_cmd_buffer.c | 147 | ||||
-rw-r--r-- | src/vulkan/gen7_pipeline.c | 3 | ||||
-rw-r--r-- | src/vulkan/gen7_state.c | 253 | ||||
-rw-r--r-- | src/vulkan/gen8_cmd_buffer.c | 150 | ||||
-rw-r--r-- | src/vulkan/gen8_pipeline.c | 4 | ||||
-rw-r--r-- | src/vulkan/gen8_state.c | 303 |
23 files changed, 2155 insertions, 2153 deletions
diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index 9877233bfeb..03bcefea50a 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -41,14 +41,21 @@ extern "C" { ((major << 22) | (minor << 12) | patch) // Vulkan API version supported by this file -#define VK_API_VERSION VK_MAKE_VERSION(0, 138, 2) +#define VK_API_VERSION VK_MAKE_VERSION(0, 170, 2) + + +#if defined(__cplusplus) && (_MSC_VER >= 1800 || __cplusplus >= 201103L) + #define VK_NULL_HANDLE nullptr +#else + #define VK_NULL_HANDLE 0 +#endif #define VK_DEFINE_HANDLE(obj) typedef struct obj##_T* obj; #if defined(__cplusplus) - #if (_MSC_VER >= 1800 || __cplusplus >= 201103L) + #if ((defined(_MSC_VER) && _MSC_VER >= 1800) || __cplusplus >= 201103L) // The bool operator only works if there are no implicit conversions from an obj to // a bool-compatible type, which can then be used to unintentionally violate type safety. // C++11 and above supports the "explicit" keyword on conversion operators to stop this @@ -56,13 +63,18 @@ extern "C" { // the object handle as a bool in expressions like: // if (obj) vkDestroy(obj); #define VK_NONDISP_HANDLE_OPERATOR_BOOL() explicit operator bool() const { return handle != 0; } + #define VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \ + explicit obj(uint64_t x) : handle(x) { } \ + obj(decltype(nullptr)) : handle(0) { } #else #define VK_NONDISP_HANDLE_OPERATOR_BOOL() + #define VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \ + obj(uint64_t x) : handle(x) { } #endif #define VK_DEFINE_NONDISP_HANDLE(obj) \ struct obj { \ obj() : handle(0) { } \ - obj(uint64_t x) : handle(x) { } \ + VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \ obj& operator =(uint64_t x) { handle = x; return *this; } \ bool operator==(const obj& other) const { return handle == other.handle; } \ bool operator!=(const obj& other) const { return handle != other.handle; } \ @@ -76,20 +88,10 @@ extern "C" { -#define VK_LOD_CLAMP_NONE MAX_FLOAT -#define VK_LAST_MIP_LEVEL UINT32_MAX -#define VK_LAST_ARRAY_SLICE UINT32_MAX -#define VK_WHOLE_SIZE UINT64_MAX -#define VK_ATTACHMENT_UNUSED UINT32_MAX -#define VK_TRUE 1 -#define VK_FALSE 0 -#define VK_NULL_HANDLE 0 -#define VK_MAX_PHYSICAL_DEVICE_NAME 256 -#define VK_UUID_LENGTH 16 -#define VK_MAX_MEMORY_TYPES 32 -#define VK_MAX_MEMORY_HEAPS 16 -#define VK_MAX_EXTENSION_NAME 256 -#define VK_MAX_DESCRIPTION 256 +typedef uint32_t VkBool32; +typedef uint32_t VkFlags; +typedef uint64_t VkDeviceSize; +typedef uint32_t VkSampleMask; VK_DEFINE_HANDLE(VkInstance) VK_DEFINE_HANDLE(VkPhysicalDevice) @@ -105,7 +107,6 @@ VK_DEFINE_NONDISP_HANDLE(VkEvent) VK_DEFINE_NONDISP_HANDLE(VkQueryPool) VK_DEFINE_NONDISP_HANDLE(VkBufferView) VK_DEFINE_NONDISP_HANDLE(VkImageView) -VK_DEFINE_NONDISP_HANDLE(VkAttachmentView) VK_DEFINE_NONDISP_HANDLE(VkShaderModule) VK_DEFINE_NONDISP_HANDLE(VkShader) VK_DEFINE_NONDISP_HANDLE(VkPipelineCache) @@ -116,13 +117,25 @@ VK_DEFINE_NONDISP_HANDLE(VkDescriptorSetLayout) VK_DEFINE_NONDISP_HANDLE(VkSampler) VK_DEFINE_NONDISP_HANDLE(VkDescriptorPool) VK_DEFINE_NONDISP_HANDLE(VkDescriptorSet) -VK_DEFINE_NONDISP_HANDLE(VkDynamicViewportState) -VK_DEFINE_NONDISP_HANDLE(VkDynamicRasterState) -VK_DEFINE_NONDISP_HANDLE(VkDynamicColorBlendState) -VK_DEFINE_NONDISP_HANDLE(VkDynamicDepthStencilState) VK_DEFINE_NONDISP_HANDLE(VkFramebuffer) VK_DEFINE_NONDISP_HANDLE(VkCmdPool) +#define VK_LOD_CLAMP_NONE 1000.0f +#define VK_REMAINING_MIP_LEVELS (~0U) +#define VK_REMAINING_ARRAY_LAYERS (~0U) +#define VK_WHOLE_SIZE (~0ULL) +#define VK_ATTACHMENT_UNUSED (~0U) +#define VK_TRUE 1 +#define VK_FALSE 0 +#define VK_QUEUE_FAMILY_IGNORED (~0U) +#define VK_SUBPASS_EXTERNAL (~0U) +#define VK_MAX_PHYSICAL_DEVICE_NAME 256 +#define VK_UUID_LENGTH 16 +#define VK_MAX_MEMORY_TYPES 32 +#define VK_MAX_MEMORY_HEAPS 16 +#define VK_MAX_EXTENSION_NAME 256 +#define VK_MAX_DESCRIPTION 256 + typedef enum { VK_SUCCESS = 0, @@ -132,41 +145,17 @@ typedef enum { VK_EVENT_SET = 4, VK_EVENT_RESET = 5, VK_INCOMPLETE = 6, - VK_ERROR_UNKNOWN = -1, - VK_ERROR_UNAVAILABLE = -2, + VK_ERROR_OUT_OF_HOST_MEMORY = -1, + VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, VK_ERROR_INITIALIZATION_FAILED = -3, - VK_ERROR_OUT_OF_HOST_MEMORY = -4, - VK_ERROR_OUT_OF_DEVICE_MEMORY = -5, - VK_ERROR_DEVICE_ALREADY_CREATED = -6, - VK_ERROR_DEVICE_LOST = -7, - VK_ERROR_INVALID_POINTER = -8, - VK_ERROR_INVALID_VALUE = -9, - VK_ERROR_INVALID_HANDLE = -10, - VK_ERROR_INVALID_ORDINAL = -11, - VK_ERROR_INVALID_MEMORY_SIZE = -12, - VK_ERROR_INVALID_EXTENSION = -13, - VK_ERROR_INVALID_FLAGS = -14, - VK_ERROR_INVALID_ALIGNMENT = -15, - VK_ERROR_INVALID_FORMAT = -16, - VK_ERROR_INVALID_IMAGE = -17, - VK_ERROR_INVALID_DESCRIPTOR_SET_DATA = -18, - VK_ERROR_INVALID_QUEUE_TYPE = -19, - VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION = -20, - VK_ERROR_BAD_SHADER_CODE = -21, - VK_ERROR_BAD_PIPELINE_DATA = -22, - VK_ERROR_NOT_MAPPABLE = -23, - VK_ERROR_MEMORY_MAP_FAILED = -24, - VK_ERROR_MEMORY_UNMAP_FAILED = -25, - VK_ERROR_INCOMPATIBLE_DEVICE = -26, - VK_ERROR_INCOMPATIBLE_DRIVER = -27, - VK_ERROR_INCOMPLETE_COMMAND_BUFFER = -28, - VK_ERROR_BUILDING_COMMAND_BUFFER = -29, - VK_ERROR_MEMORY_NOT_BOUND = -30, - VK_ERROR_INCOMPATIBLE_QUEUE = -31, - VK_ERROR_INVALID_LAYER = -32, - VK_RESULT_BEGIN_RANGE = VK_ERROR_INVALID_LAYER, + VK_ERROR_DEVICE_LOST = -4, + VK_ERROR_MEMORY_MAP_FAILED = -5, + VK_ERROR_LAYER_NOT_PRESENT = -6, + VK_ERROR_EXTENSION_NOT_PRESENT = -7, + VK_ERROR_INCOMPATIBLE_DRIVER = -8, + VK_RESULT_BEGIN_RANGE = VK_ERROR_INCOMPATIBLE_DRIVER, VK_RESULT_END_RANGE = VK_INCOMPLETE, - VK_RESULT_NUM = (VK_INCOMPLETE - VK_ERROR_INVALID_LAYER + 1), + VK_RESULT_NUM = (VK_INCOMPLETE - VK_ERROR_INCOMPATIBLE_DRIVER + 1), VK_RESULT_MAX_ENUM = 0x7FFFFFFF } VkResult; @@ -175,55 +164,52 @@ typedef enum { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 1, VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO = 2, VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 3, - VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO = 4, - VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 5, - VK_STRUCTURE_TYPE_SHADER_CREATE_INFO = 6, - VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 7, - VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 8, - VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 9, - VK_STRUCTURE_TYPE_DYNAMIC_VIEWPORT_STATE_CREATE_INFO = 10, - VK_STRUCTURE_TYPE_DYNAMIC_RASTER_STATE_CREATE_INFO = 11, - VK_STRUCTURE_TYPE_DYNAMIC_COLOR_BLEND_STATE_CREATE_INFO = 12, - VK_STRUCTURE_TYPE_DYNAMIC_DEPTH_STENCIL_STATE_CREATE_INFO = 13, - VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO = 14, - VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 15, - VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 16, - VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 17, - VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 18, - VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 19, - VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 20, - VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 21, - VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 22, - VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 23, - VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 24, - VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO = 25, - VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 26, - VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 27, - VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 28, - VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 29, - VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 30, - VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 31, - VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 32, - VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO = 33, - VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 34, - VK_STRUCTURE_TYPE_MEMORY_BARRIER = 35, - VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 36, - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 37, - VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 38, - VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 39, - VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 40, - VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 41, - VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 42, - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 43, - VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 44, - VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION = 45, - VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION = 46, - VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY = 47, - VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 48, - VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO = 49, + VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 4, + VK_STRUCTURE_TYPE_SHADER_CREATE_INFO = 5, + VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 6, + VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 7, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 8, + VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO = 9, + VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10, + VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 11, + VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 12, + VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 13, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 14, + VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 15, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 16, + VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 17, + VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 18, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 19, + VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO = 20, + VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 21, + VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 22, + VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 23, + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 24, + VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 25, + VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 26, + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 27, + VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO = 28, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 29, + VK_STRUCTURE_TYPE_MEMORY_BARRIER = 30, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 31, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 32, + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 34, + VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 35, + VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 36, + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 37, + VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 38, + VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 39, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION = 40, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION = 41, + VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY = 42, + VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43, + VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO = 44, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 45, + VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 46, VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO, - VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO, - VK_STRUCTURE_TYPE_NUM = (VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), + VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, + VK_STRUCTURE_TYPE_NUM = (VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF } VkStructureType; @@ -330,7 +316,7 @@ typedef enum { VK_FORMAT_R11G11B10_UFLOAT = 87, VK_FORMAT_R9G9B9E5_UFLOAT = 88, VK_FORMAT_D16_UNORM = 89, - VK_FORMAT_D24_UNORM = 90, + VK_FORMAT_D24_UNORM_X8 = 90, VK_FORMAT_D32_SFLOAT = 91, VK_FORMAT_S8_UINT = 92, VK_FORMAT_D16_UNORM_S8_UINT = 93, @@ -481,13 +467,20 @@ typedef enum { } VkSharingMode; typedef enum { - VK_BUFFER_VIEW_TYPE_RAW = 0, - VK_BUFFER_VIEW_TYPE_FORMATTED = 1, - VK_BUFFER_VIEW_TYPE_BEGIN_RANGE = VK_BUFFER_VIEW_TYPE_RAW, - VK_BUFFER_VIEW_TYPE_END_RANGE = VK_BUFFER_VIEW_TYPE_FORMATTED, - VK_BUFFER_VIEW_TYPE_NUM = (VK_BUFFER_VIEW_TYPE_FORMATTED - VK_BUFFER_VIEW_TYPE_RAW + 1), - VK_BUFFER_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkBufferViewType; + VK_IMAGE_LAYOUT_UNDEFINED = 0, + VK_IMAGE_LAYOUT_GENERAL = 1, + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5, + VK_IMAGE_LAYOUT_TRANSFER_SOURCE_OPTIMAL = 6, + VK_IMAGE_LAYOUT_TRANSFER_DESTINATION_OPTIMAL = 7, + VK_IMAGE_LAYOUT_PREINITIALIZED = 8, + VK_IMAGE_LAYOUT_BEGIN_RANGE = VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_END_RANGE = VK_IMAGE_LAYOUT_PREINITIALIZED, + VK_IMAGE_LAYOUT_NUM = (VK_IMAGE_LAYOUT_PREINITIALIZED - VK_IMAGE_LAYOUT_UNDEFINED + 1), + VK_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF +} VkImageLayout; typedef enum { VK_IMAGE_VIEW_TYPE_1D = 0, @@ -678,6 +671,22 @@ typedef enum { } VkBlendOp; typedef enum { + VK_DYNAMIC_STATE_VIEWPORT = 0, + VK_DYNAMIC_STATE_SCISSOR = 1, + VK_DYNAMIC_STATE_LINE_WIDTH = 2, + VK_DYNAMIC_STATE_DEPTH_BIAS = 3, + VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4, + VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5, + VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6, + VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7, + VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8, + VK_DYNAMIC_STATE_BEGIN_RANGE = VK_DYNAMIC_STATE_VIEWPORT, + VK_DYNAMIC_STATE_END_RANGE = VK_DYNAMIC_STATE_STENCIL_REFERENCE, + VK_DYNAMIC_STATE_NUM = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1), + VK_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF +} VkDynamicState; + +typedef enum { VK_TEX_FILTER_NEAREST = 0, VK_TEX_FILTER_LINEAR = 1, VK_TEX_FILTER_BEGIN_RANGE = VK_TEX_FILTER_NEAREST, @@ -697,16 +706,16 @@ typedef enum { } VkTexMipmapMode; typedef enum { - VK_TEX_ADDRESS_WRAP = 0, - VK_TEX_ADDRESS_MIRROR = 1, - VK_TEX_ADDRESS_CLAMP = 2, - VK_TEX_ADDRESS_MIRROR_ONCE = 3, - VK_TEX_ADDRESS_CLAMP_BORDER = 4, - VK_TEX_ADDRESS_BEGIN_RANGE = VK_TEX_ADDRESS_WRAP, - VK_TEX_ADDRESS_END_RANGE = VK_TEX_ADDRESS_CLAMP_BORDER, - VK_TEX_ADDRESS_NUM = (VK_TEX_ADDRESS_CLAMP_BORDER - VK_TEX_ADDRESS_WRAP + 1), + VK_TEX_ADDRESS_MODE_WRAP = 0, + VK_TEX_ADDRESS_MODE_MIRROR = 1, + VK_TEX_ADDRESS_MODE_CLAMP = 2, + VK_TEX_ADDRESS_MODE_MIRROR_ONCE = 3, + VK_TEX_ADDRESS_MODE_CLAMP_BORDER = 4, + VK_TEX_ADDRESS_BEGIN_RANGE = VK_TEX_ADDRESS_MODE_WRAP, + VK_TEX_ADDRESS_END_RANGE = VK_TEX_ADDRESS_MODE_CLAMP_BORDER, + VK_TEX_ADDRESS_NUM = (VK_TEX_ADDRESS_MODE_CLAMP_BORDER - VK_TEX_ADDRESS_MODE_WRAP + 1), VK_TEX_ADDRESS_MAX_ENUM = 0x7FFFFFFF -} VkTexAddress; +} VkTexAddressMode; typedef enum { VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0, @@ -758,21 +767,6 @@ typedef enum { } VkDescriptorSetUsage; typedef enum { - VK_IMAGE_LAYOUT_UNDEFINED = 0, - VK_IMAGE_LAYOUT_GENERAL = 1, - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2, - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3, - VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4, - VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5, - VK_IMAGE_LAYOUT_TRANSFER_SOURCE_OPTIMAL = 6, - VK_IMAGE_LAYOUT_TRANSFER_DESTINATION_OPTIMAL = 7, - VK_IMAGE_LAYOUT_BEGIN_RANGE = VK_IMAGE_LAYOUT_UNDEFINED, - VK_IMAGE_LAYOUT_END_RANGE = VK_IMAGE_LAYOUT_TRANSFER_DESTINATION_OPTIMAL, - VK_IMAGE_LAYOUT_NUM = (VK_IMAGE_LAYOUT_TRANSFER_DESTINATION_OPTIMAL - VK_IMAGE_LAYOUT_UNDEFINED + 1), - VK_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF -} VkImageLayout; - -typedef enum { VK_ATTACHMENT_LOAD_OP_LOAD = 0, VK_ATTACHMENT_LOAD_OP_CLEAR = 1, VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2, @@ -848,24 +842,44 @@ typedef enum { VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0x00000080, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 0x00000100, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000200, - VK_FORMAT_FEATURE_CONVERSION_BIT = 0x00000400, + VK_FORMAT_FEATURE_BLIT_SOURCE_BIT = 0x00000400, + VK_FORMAT_FEATURE_BLIT_DESTINATION_BIT = 0x00000800, } VkFormatFeatureFlagBits; typedef VkFlags VkFormatFeatureFlags; typedef enum { - VK_IMAGE_USAGE_GENERAL = 0, VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT = 0x00000001, VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT = 0x00000002, VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010, - VK_IMAGE_USAGE_DEPTH_STENCIL_BIT = 0x00000020, + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080, } VkImageUsageFlagBits; typedef VkFlags VkImageUsageFlags; typedef enum { + VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001, + VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, + VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, + VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008, + VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010, +} VkImageCreateFlagBits; +typedef VkFlags VkImageCreateFlags; + +typedef enum { + VK_SAMPLE_COUNT_1_BIT = 0x00000001, + VK_SAMPLE_COUNT_2_BIT = 0x00000002, + VK_SAMPLE_COUNT_4_BIT = 0x00000004, + VK_SAMPLE_COUNT_8_BIT = 0x00000008, + VK_SAMPLE_COUNT_16_BIT = 0x00000010, + VK_SAMPLE_COUNT_32_BIT = 0x00000020, + VK_SAMPLE_COUNT_64_BIT = 0x00000040, +} VkSampleCountFlagBits; +typedef VkFlags VkSampleCountFlags; + +typedef enum { VK_QUEUE_GRAPHICS_BIT = 0x00000001, VK_QUEUE_COMPUTE_BIT = 0x00000002, VK_QUEUE_DMA_BIT = 0x00000004, @@ -885,14 +899,9 @@ typedef enum { typedef VkFlags VkMemoryPropertyFlags; typedef enum { - VK_MEMORY_HEAP_HOST_LOCAL = 0x00000001, + VK_MEMORY_HEAP_HOST_LOCAL_BIT = 0x00000001, } VkMemoryHeapFlagBits; typedef VkFlags VkMemoryHeapFlags; - -typedef enum { - VK_DEVICE_CREATE_VALIDATION_BIT = 0x00000001, -} VkDeviceCreateFlagBits; -typedef VkFlags VkDeviceCreateFlags; typedef VkFlags VkMemoryMapFlags; typedef enum { @@ -939,7 +948,6 @@ typedef enum { typedef VkFlags VkQueryResultFlags; typedef enum { - VK_BUFFER_USAGE_GENERAL = 0, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT = 0x00000001, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT = 0x00000002, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004, @@ -953,27 +961,25 @@ typedef enum { typedef VkFlags VkBufferUsageFlags; typedef enum { - VK_BUFFER_CREATE_SPARSE_BIT = 0x00000001, + VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001, VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, } VkBufferCreateFlagBits; typedef VkFlags VkBufferCreateFlags; typedef enum { - VK_IMAGE_CREATE_SPARSE_BIT = 0x00000001, - VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, - VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, - VK_IMAGE_CREATE_INVARIANT_DATA_BIT = 0x00000008, - VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000010, - VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000020, -} VkImageCreateFlagBits; -typedef VkFlags VkImageCreateFlags; + VK_IMAGE_ASPECT_COLOR_BIT = 0x00000001, + VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002, + VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004, + VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008, +} VkImageAspectFlagBits; +typedef VkFlags VkImageAspectFlags; typedef enum { - VK_ATTACHMENT_VIEW_CREATE_READ_ONLY_DEPTH_BIT = 0x00000001, - VK_ATTACHMENT_VIEW_CREATE_READ_ONLY_STENCIL_BIT = 0x00000002, -} VkAttachmentViewCreateFlagBits; -typedef VkFlags VkAttachmentViewCreateFlags; + VK_IMAGE_VIEW_CREATE_READ_ONLY_DEPTH_BIT = 0x00000001, + VK_IMAGE_VIEW_CREATE_READ_ONLY_STENCIL_BIT = 0x00000002, +} VkImageViewCreateFlagBits; +typedef VkFlags VkImageViewCreateFlags; typedef VkFlags VkShaderModuleCreateFlags; typedef VkFlags VkShaderCreateFlags; @@ -1004,6 +1010,11 @@ typedef enum { typedef VkFlags VkShaderStageFlags; typedef enum { + VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001, +} VkAttachmentDescriptionFlagBits; +typedef VkFlags VkAttachmentDescriptionFlags; + +typedef enum { VK_SUBPASS_DESCRIPTION_NO_OVERDRAW_BIT = 0x00000001, } VkSubpassDescriptionFlagBits; typedef VkFlags VkSubpassDescriptionFlags; @@ -1022,10 +1033,9 @@ typedef enum { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800, VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000, - VK_PIPELINE_STAGE_TRANSITION_BIT = 0x00002000, - VK_PIPELINE_STAGE_HOST_BIT = 0x00004000, + VK_PIPELINE_STAGE_HOST_BIT = 0x00002000, VK_PIPELINE_STAGE_ALL_GRAPHICS = 0x000007FF, - VK_PIPELINE_STAGE_ALL_GPU_COMMANDS = 0x00003FFF, + VK_PIPELINE_STAGE_ALL_GPU_COMMANDS = 0x00001FFF, } VkPipelineStageFlagBits; typedef VkFlags VkPipelineStageFlags; @@ -1059,7 +1069,7 @@ typedef enum { typedef VkFlags VkCmdPoolCreateFlags; typedef enum { - VK_CMD_POOL_RESET_RELEASE_RESOURCES = 0x00000001, + VK_CMD_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001, } VkCmdPoolResetFlagBits; typedef VkFlags VkCmdPoolResetFlags; typedef VkFlags VkCmdBufferCreateFlags; @@ -1074,33 +1084,22 @@ typedef enum { typedef VkFlags VkCmdBufferOptimizeFlags; typedef enum { - VK_CMD_BUFFER_RESET_RELEASE_RESOURCES = 0x00000001, + VK_CMD_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001, } VkCmdBufferResetFlagBits; typedef VkFlags VkCmdBufferResetFlags; typedef enum { - VK_IMAGE_ASPECT_COLOR_BIT = 0x00000001, - VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002, - VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004, - VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008, -} VkImageAspectFlagBits; -typedef VkFlags VkImageAspectFlags; + VK_STENCIL_FACE_NONE = 0, + VK_STENCIL_FACE_FRONT_BIT = 0x00000001, + VK_STENCIL_FACE_BACK_BIT = 0x00000002, +} VkStencilFaceFlagBits; +typedef VkFlags VkStencilFaceFlags; typedef enum { VK_QUERY_CONTROL_CONSERVATIVE_BIT = 0x00000001, } VkQueryControlFlagBits; typedef VkFlags VkQueryControlFlags; -typedef struct { - VkStructureType sType; - const void* pNext; - const char* pAppName; - uint32_t appVersion; - const char* pEngineName; - uint32_t engineVersion; - uint32_t apiVersion; -} VkApplicationInfo; - typedef void* (VKAPI *PFN_vkAllocFunction)( void* pUserData, size_t size, @@ -1111,6 +1110,18 @@ typedef void (VKAPI *PFN_vkFreeFunction)( void* pUserData, void* pMem); +typedef void (VKAPI *PFN_vkVoidFunction)(void); + +typedef struct { + VkStructureType sType; + const void* pNext; + const char* pAppName; + uint32_t appVersion; + const char* pEngineName; + uint32_t engineVersion; + uint32_t apiVersion; +} VkApplicationInfo; + typedef struct { void* pUserData; PFN_vkAllocFunction pfnAlloc; @@ -1138,7 +1149,7 @@ typedef struct { VkBool32 sampleRateShading; VkBool32 dualSourceBlend; VkBool32 logicOp; - VkBool32 instancedDrawIndirect; + VkBool32 multiDrawIndirect; VkBool32 depthClip; VkBool32 depthBiasClamp; VkBool32 fillModeNonSolid; @@ -1148,6 +1159,7 @@ typedef struct { VkBool32 textureCompressionETC2; VkBool32 textureCompressionASTC_LDR; VkBool32 textureCompressionBC; + VkBool32 occlusionQueryNonConservative; VkBool32 pipelineStatisticsQuery; VkBool32 vertexSideEffects; VkBool32 tessellationSideEffects; @@ -1155,11 +1167,9 @@ typedef struct { VkBool32 fragmentSideEffects; VkBool32 shaderTessellationPointSize; VkBool32 shaderGeometryPointSize; - VkBool32 shaderTextureGatherExtended; + VkBool32 shaderImageGatherExtended; VkBool32 shaderStorageImageExtendedFormats; VkBool32 shaderStorageImageMultisample; - VkBool32 shaderStorageBufferArrayConstantIndexing; - VkBool32 shaderStorageImageArrayConstantIndexing; VkBool32 shaderUniformBufferArrayDynamicIndexing; VkBool32 shaderSampledImageArrayDynamicIndexing; VkBool32 shaderStorageBufferArrayDynamicIndexing; @@ -1168,11 +1178,11 @@ typedef struct { VkBool32 shaderCullDistance; VkBool32 shaderFloat64; VkBool32 shaderInt64; - VkBool32 shaderFloat16; VkBool32 shaderInt16; VkBool32 shaderResourceResidency; VkBool32 shaderResourceMinLOD; - VkBool32 sparse; + VkBool32 alphaToOne; + VkBool32 sparseBinding; VkBool32 sparseResidencyBuffer; VkBool32 sparseResidencyImage2D; VkBool32 sparseResidencyImage3D; @@ -1180,23 +1190,27 @@ typedef struct { VkBool32 sparseResidency4Samples; VkBool32 sparseResidency8Samples; VkBool32 sparseResidency16Samples; - VkBool32 sparseResidencyStandard2DBlockShape; - VkBool32 sparseResidencyStandard2DMSBlockShape; - VkBool32 sparseResidencyStandard3DBlockShape; - VkBool32 sparseResidencyAlignedMipSize; - VkBool32 sparseResidencyNonResident; - VkBool32 sparseResidencyNonResidentStrict; VkBool32 sparseResidencyAliased; } VkPhysicalDeviceFeatures; typedef struct { VkFormatFeatureFlags linearTilingFeatures; VkFormatFeatureFlags optimalTilingFeatures; + VkFormatFeatureFlags bufferFeatures; } VkFormatProperties; typedef struct { - uint64_t maxResourceSize; - uint32_t maxSamples; + int32_t width; + int32_t height; + int32_t depth; +} VkExtent3D; + +typedef struct { + VkExtent3D maxExtent; + uint32_t maxMipLevels; + uint32_t maxArraySize; + VkSampleCountFlags sampleCounts; + VkDeviceSize maxResourceSize; } VkImageFormatProperties; typedef struct { @@ -1205,12 +1219,14 @@ typedef struct { uint32_t maxImageDimension3D; uint32_t maxImageDimensionCube; uint32_t maxImageArrayLayers; + VkSampleCountFlags sampleCounts; uint32_t maxTexelBufferSize; uint32_t maxUniformBufferSize; uint32_t maxStorageBufferSize; uint32_t maxPushConstantsSize; uint32_t maxMemoryAllocationCount; VkDeviceSize bufferImageGranularity; + VkDeviceSize sparseAddressSpaceSize; uint32_t maxBoundDescriptorSets; uint32_t maxDescriptorSets; uint32_t maxPerStageDescriptorSamplers; @@ -1220,10 +1236,13 @@ typedef struct { uint32_t maxPerStageDescriptorStorageImages; uint32_t maxDescriptorSetSamplers; uint32_t maxDescriptorSetUniformBuffers; + uint32_t maxDescriptorSetUniformBuffersDynamic; uint32_t maxDescriptorSetStorageBuffers; + uint32_t maxDescriptorSetStorageBuffersDynamic; uint32_t maxDescriptorSetSampledImages; uint32_t maxDescriptorSetStorageImages; uint32_t maxVertexInputAttributes; + uint32_t maxVertexInputBindings; uint32_t maxVertexInputAttributeOffset; uint32_t maxVertexInputBindingStride; uint32_t maxVertexOutputComponents; @@ -1257,7 +1276,6 @@ typedef struct { float maxSamplerLodBias; float maxSamplerAnisotropy; uint32_t maxViewports; - uint32_t maxDynamicViewportStates; uint32_t maxViewportDimensions[2]; float viewportBoundsRange[2]; uint32_t viewportSubPixelBits; @@ -1295,6 +1313,15 @@ typedef struct { } VkPhysicalDeviceLimits; typedef struct { + VkBool32 residencyStandard2DBlockShape; + VkBool32 residencyStandard2DMSBlockShape; + VkBool32 residencyStandard3DBlockShape; + VkBool32 residencyAlignedMipSize; + VkBool32 residencyNonResident; + VkBool32 residencyNonResidentStrict; +} VkPhysicalDeviceSparseProperties; + +typedef struct { uint32_t apiVersion; uint32_t driverVersion; uint32_t vendorId; @@ -1302,13 +1329,15 @@ typedef struct { VkPhysicalDeviceType deviceType; char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME]; uint8_t pipelineCacheUUID[VK_UUID_LENGTH]; + VkPhysicalDeviceLimits limits; + VkPhysicalDeviceSparseProperties sparseProperties; } VkPhysicalDeviceProperties; typedef struct { VkQueueFlags queueFlags; uint32_t queueCount; VkBool32 supportsTimestamps; -} VkPhysicalDeviceQueueProperties; +} VkQueueFamilyProperties; typedef struct { VkMemoryPropertyFlags propertyFlags; @@ -1327,8 +1356,9 @@ typedef struct { VkMemoryHeap memoryHeaps[VK_MAX_MEMORY_HEAPS]; } VkPhysicalDeviceMemoryProperties; -typedef void (VKAPI *PFN_vkVoidFunction)(void); typedef struct { + VkStructureType sType; + const void* pNext; uint32_t queueFamilyIndex; uint32_t queueCount; } VkDeviceQueueCreateInfo; @@ -1343,7 +1373,6 @@ typedef struct { uint32_t extensionCount; const char*const* ppEnabledExtensionNames; const VkPhysicalDeviceFeatures* pEnabledFeatures; - VkDeviceCreateFlags flags; } VkDeviceCreateInfo; typedef struct { @@ -1380,12 +1409,6 @@ typedef struct { } VkMemoryRequirements; typedef struct { - int32_t width; - int32_t height; - int32_t depth; -} VkExtent3D; - -typedef struct { VkImageAspect aspect; VkExtent3D imageGranularity; VkSparseImageFormatFlags flags; @@ -1410,7 +1433,7 @@ typedef struct { typedef struct { VkImageAspect aspect; uint32_t mipLevel; - uint32_t arraySlice; + uint32_t arrayLayer; } VkImageSubresource; typedef struct { @@ -1469,7 +1492,6 @@ typedef struct { VkStructureType sType; const void* pNext; VkBuffer buffer; - VkBufferViewType viewType; VkFormat format; VkDeviceSize offset; VkDeviceSize range; @@ -1490,6 +1512,7 @@ typedef struct { VkSharingMode sharingMode; uint32_t queueFamilyCount; const uint32_t* pQueueFamilyIndices; + VkImageLayout initialLayout; } VkImageCreateInfo; typedef struct { @@ -1507,10 +1530,10 @@ typedef struct { } VkChannelMapping; typedef struct { - VkImageAspect aspect; + VkImageAspectFlags aspectMask; uint32_t baseMipLevel; uint32_t mipLevels; - uint32_t baseArraySlice; + uint32_t baseArrayLayer; uint32_t arraySize; } VkImageSubresourceRange; @@ -1522,22 +1545,12 @@ typedef struct { VkFormat format; VkChannelMapping channels; VkImageSubresourceRange subresourceRange; + VkImageViewCreateFlags flags; } VkImageViewCreateInfo; typedef struct { VkStructureType sType; const void* pNext; - VkImage image; - VkFormat format; - uint32_t mipLevel; - uint32_t baseArraySlice; - uint32_t arraySize; - VkAttachmentViewCreateFlags flags; -} VkAttachmentViewCreateInfo; - -typedef struct { - VkStructureType sType; - const void* pNext; size_t codeSize; const void* pCode; VkShaderModuleCreateFlags flags; @@ -1549,6 +1562,7 @@ typedef struct { VkShaderModule module; const char* pName; VkShaderCreateFlags flags; + VkShaderStage stage; } VkShaderCreateInfo; typedef struct { @@ -1616,9 +1630,36 @@ typedef struct { } VkPipelineTessellationStateCreateInfo; typedef struct { + float originX; + float originY; + float width; + float height; + float minDepth; + float maxDepth; +} VkViewport; + +typedef struct { + int32_t x; + int32_t y; +} VkOffset2D; + +typedef struct { + int32_t width; + int32_t height; +} VkExtent2D; + +typedef struct { + VkOffset2D offset; + VkExtent2D extent; +} VkRect2D; + +typedef struct { VkStructureType sType; const void* pNext; uint32_t viewportCount; + const VkViewport* pViewports; + uint32_t scissorCount; + const VkRect2D* pScissors; } VkPipelineViewportStateCreateInfo; typedef struct { @@ -1629,6 +1670,11 @@ typedef struct { VkFillMode fillMode; VkCullMode cullMode; VkFrontFace frontFace; + VkBool32 depthBiasEnable; + float depthBias; + float depthBiasClamp; + float slopeScaledDepthBias; + float lineWidth; } VkPipelineRasterStateCreateInfo; typedef struct { @@ -1637,7 +1683,7 @@ typedef struct { uint32_t rasterSamples; VkBool32 sampleShadingEnable; float minSampleShading; - VkSampleMask sampleMask; + const VkSampleMask* pSampleMask; } VkPipelineMultisampleStateCreateInfo; typedef struct { @@ -1645,6 +1691,9 @@ typedef struct { VkStencilOp stencilPassOp; VkStencilOp stencilDepthFailOp; VkCompareOp stencilCompareOp; + uint32_t stencilCompareMask; + uint32_t stencilWriteMask; + uint32_t stencilReference; } VkStencilOpState; typedef struct { @@ -1653,10 +1702,12 @@ typedef struct { VkBool32 depthTestEnable; VkBool32 depthWriteEnable; VkCompareOp depthCompareOp; - VkBool32 depthBoundsEnable; + VkBool32 depthBoundsTestEnable; VkBool32 stencilTestEnable; VkStencilOpState front; VkStencilOpState back; + float minDepthBounds; + float maxDepthBounds; } VkPipelineDepthStencilStateCreateInfo; typedef struct { @@ -1674,15 +1725,24 @@ typedef struct { VkStructureType sType; const void* pNext; VkBool32 alphaToCoverageEnable; + VkBool32 alphaToOneEnable; VkBool32 logicOpEnable; VkLogicOp logicOp; uint32_t attachmentCount; const VkPipelineColorBlendAttachmentState* pAttachments; + float blendConst[4]; } VkPipelineColorBlendStateCreateInfo; typedef struct { VkStructureType sType; const void* pNext; + uint32_t dynamicStateCount; + const VkDynamicState* pDynamicStates; +} VkPipelineDynamicStateCreateInfo; + +typedef struct { + VkStructureType sType; + const void* pNext; uint32_t stageCount; const VkPipelineShaderStageCreateInfo* pStages; const VkPipelineVertexInputStateCreateInfo* pVertexInputState; @@ -1693,6 +1753,7 @@ typedef struct { const VkPipelineMultisampleStateCreateInfo* pMultisampleState; const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState; const VkPipelineColorBlendStateCreateInfo* pColorBlendState; + const VkPipelineDynamicStateCreateInfo* pDynamicState; VkPipelineCreateFlags flags; VkPipelineLayout layout; VkRenderPass renderPass; @@ -1704,7 +1765,7 @@ typedef struct { typedef struct { VkStructureType sType; const void* pNext; - VkPipelineShaderStageCreateInfo cs; + VkPipelineShaderStageCreateInfo stage; VkPipelineCreateFlags flags; VkPipelineLayout layout; VkPipeline basePipelineHandle; @@ -1732,9 +1793,9 @@ typedef struct { VkTexFilter magFilter; VkTexFilter minFilter; VkTexMipmapMode mipMode; - VkTexAddress addressU; - VkTexAddress addressV; - VkTexAddress addressW; + VkTexAddressMode addressModeU; + VkTexAddressMode addressModeV; + VkTexAddressMode addressModeW; float mipLodBias; float maxAnisotropy; VkBool32 compareEnable; @@ -1742,6 +1803,7 @@ typedef struct { float minLod; float maxLod; VkBorderColor borderColor; + VkBool32 unnormalizedCoordinates; } VkSamplerCreateInfo; typedef struct { @@ -1766,16 +1828,24 @@ typedef struct { typedef struct { VkStructureType sType; const void* pNext; + VkDescriptorPoolUsage poolUsage; + uint32_t maxSets; uint32_t count; const VkDescriptorTypeCount* pTypeCount; } VkDescriptorPoolCreateInfo; typedef struct { + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize range; +} VkDescriptorBufferInfo; + +typedef struct { VkBufferView bufferView; VkSampler sampler; VkImageView imageView; - VkAttachmentView attachmentView; VkImageLayout imageLayout; + VkDescriptorBufferInfo bufferInfo; } VkDescriptorInfo; typedef struct { @@ -1802,74 +1872,11 @@ typedef struct { } VkCopyDescriptorSet; typedef struct { - float originX; - float originY; - float width; - float height; - float minDepth; - float maxDepth; -} VkViewport; - -typedef struct { - int32_t x; - int32_t y; -} VkOffset2D; - -typedef struct { - int32_t width; - int32_t height; -} VkExtent2D; - -typedef struct { - VkOffset2D offset; - VkExtent2D extent; -} VkRect2D; - -typedef struct { - VkStructureType sType; - const void* pNext; - uint32_t viewportAndScissorCount; - const VkViewport* pViewports; - const VkRect2D* pScissors; -} VkDynamicViewportStateCreateInfo; - -typedef struct { - VkStructureType sType; - const void* pNext; - float depthBias; - float depthBiasClamp; - float slopeScaledDepthBias; - float lineWidth; -} VkDynamicRasterStateCreateInfo; - -typedef struct { - VkStructureType sType; - const void* pNext; - float blendConst[4]; -} VkDynamicColorBlendStateCreateInfo; - -typedef struct { - VkStructureType sType; - const void* pNext; - float minDepthBounds; - float maxDepthBounds; - uint32_t stencilReadMask; - uint32_t stencilWriteMask; - uint32_t stencilFrontRef; - uint32_t stencilBackRef; -} VkDynamicDepthStencilStateCreateInfo; - -typedef struct { - VkAttachmentView view; - VkImageLayout layout; -} VkAttachmentBindInfo; - -typedef struct { VkStructureType sType; const void* pNext; VkRenderPass renderPass; uint32_t attachmentCount; - const VkAttachmentBindInfo* pAttachments; + const VkImageView* pAttachments; uint32_t width; uint32_t height; uint32_t layers; @@ -1886,6 +1893,7 @@ typedef struct { VkAttachmentStoreOp stencilStoreOp; VkImageLayout initialLayout; VkImageLayout finalLayout; + VkAttachmentDescriptionFlags flags; } VkAttachmentDescription; typedef struct { @@ -1899,13 +1907,13 @@ typedef struct { VkPipelineBindPoint pipelineBindPoint; VkSubpassDescriptionFlags flags; uint32_t inputCount; - const VkAttachmentReference* inputAttachments; + const VkAttachmentReference* pInputAttachments; uint32_t colorCount; - const VkAttachmentReference* colorAttachments; - const VkAttachmentReference* resolveAttachments; + const VkAttachmentReference* pColorAttachments; + const VkAttachmentReference* pResolveAttachments; VkAttachmentReference depthStencilAttachment; uint32_t preserveCount; - const VkAttachmentReference* preserveAttachments; + const VkAttachmentReference* pPreserveAttachments; } VkSubpassDescription; typedef struct { @@ -1951,6 +1959,7 @@ typedef struct { const void* pNext; VkCmdBufferOptimizeFlags flags; VkRenderPass renderPass; + uint32_t subpass; VkFramebuffer framebuffer; } VkCmdBufferBeginInfo; @@ -1961,18 +1970,25 @@ typedef struct { } VkBufferCopy; typedef struct { - VkImageSubresource srcSubresource; + VkImageAspect aspect; + uint32_t mipLevel; + uint32_t arrayLayer; + uint32_t arraySize; +} VkImageSubresourceCopy; + +typedef struct { + VkImageSubresourceCopy srcSubresource; VkOffset3D srcOffset; - VkImageSubresource destSubresource; + VkImageSubresourceCopy destSubresource; VkOffset3D destOffset; VkExtent3D extent; } VkImageCopy; typedef struct { - VkImageSubresource srcSubresource; + VkImageSubresourceCopy srcSubresource; VkOffset3D srcOffset; VkExtent3D srcExtent; - VkImageSubresource destSubresource; + VkImageSubresourceCopy destSubresource; VkOffset3D destOffset; VkExtent3D destExtent; } VkImageBlit; @@ -1981,38 +1997,38 @@ typedef struct { VkDeviceSize bufferOffset; uint32_t bufferRowLength; uint32_t bufferImageHeight; - VkImageSubresource imageSubresource; + VkImageSubresourceCopy imageSubresource; VkOffset3D imageOffset; VkExtent3D imageExtent; } VkBufferImageCopy; typedef union { - float f32[4]; - int32_t s32[4]; - uint32_t u32[4]; + float float32[4]; + int32_t int32[4]; + uint32_t uint32[4]; } VkClearColorValue; typedef struct { + float depth; + uint32_t stencil; +} VkClearDepthStencilValue; + +typedef struct { VkOffset3D offset; VkExtent3D extent; } VkRect3D; typedef struct { - VkImageSubresource srcSubresource; + VkImageSubresourceCopy srcSubresource; VkOffset3D srcOffset; - VkImageSubresource destSubresource; + VkImageSubresourceCopy destSubresource; VkOffset3D destOffset; VkExtent3D extent; } VkImageResolve; -typedef struct { - float depth; - uint32_t stencil; -} VkClearDepthStencilValue; - typedef union { VkClearColorValue color; - VkClearDepthStencilValue ds; + VkClearDepthStencilValue depthStencil; } VkClearValue; typedef struct { @@ -2021,8 +2037,8 @@ typedef struct { VkRenderPass renderPass; VkFramebuffer framebuffer; VkRect2D renderArea; - uint32_t attachmentCount; - const VkClearValue* pAttachmentClearValues; + uint32_t clearValueCount; + const VkClearValue* pClearValues; } VkRenderPassBeginInfo; typedef struct { @@ -2080,32 +2096,30 @@ typedef struct { typedef VkResult (VKAPI *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance); -typedef VkResult (VKAPI *PFN_vkDestroyInstance)(VkInstance instance); +typedef void (VKAPI *PFN_vkDestroyInstance)(VkInstance instance); typedef VkResult (VKAPI *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures); typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageFormatProperties* pImageFormatProperties); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceLimits)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceLimits* pLimits); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties); typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceQueueCount)(VkPhysicalDevice physicalDevice, uint32_t* pCount); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceQueueProperties)(VkPhysicalDevice physicalDevice, uint32_t count, VkPhysicalDeviceQueueProperties* pQueueProperties); +typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkQueueFamilyProperties* pQueueFamilyProperties); typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties); typedef PFN_vkVoidFunction (VKAPI *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName); typedef PFN_vkVoidFunction (VKAPI *PFN_vkGetDeviceProcAddr)(VkDevice device, const char* pName); typedef VkResult (VKAPI *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice); -typedef VkResult (VKAPI *PFN_vkDestroyDevice)(VkDevice device); -typedef VkResult (VKAPI *PFN_vkGetGlobalExtensionProperties)(const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties); -typedef VkResult (VKAPI *PFN_vkGetGlobalLayerProperties)(uint32_t* pCount, VkLayerProperties* pProperties); -typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkLayerProperties* pProperties); +typedef void (VKAPI *PFN_vkDestroyDevice)(VkDevice device); +typedef VkResult (VKAPI *PFN_vkEnumerateInstanceExtensionProperties)(const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties); +typedef VkResult (VKAPI *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties); +typedef VkResult (VKAPI *PFN_vkEnumerateInstanceLayerProperties)(uint32_t* pCount, VkLayerProperties* pProperties); +typedef VkResult (VKAPI *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkLayerProperties* pProperties); typedef VkResult (VKAPI *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue); typedef VkResult (VKAPI *PFN_vkQueueSubmit)(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence); typedef VkResult (VKAPI *PFN_vkQueueWaitIdle)(VkQueue queue); typedef VkResult (VKAPI *PFN_vkDeviceWaitIdle)(VkDevice device); typedef VkResult (VKAPI *PFN_vkAllocMemory)(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem); -typedef VkResult (VKAPI *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory mem); +typedef void (VKAPI *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory mem); typedef VkResult (VKAPI *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData); -typedef VkResult (VKAPI *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory mem); +typedef void (VKAPI *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory mem); typedef VkResult (VKAPI *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges); typedef VkResult (VKAPI *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges); typedef VkResult (VKAPI *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes); @@ -2119,88 +2133,83 @@ typedef VkResult (VKAPI *PFN_vkQueueBindSparseBufferMemory)(VkQueue queue, VkBuf typedef VkResult (VKAPI *PFN_vkQueueBindSparseImageOpaqueMemory)(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseMemoryBindInfo* pBindInfo); typedef VkResult (VKAPI *PFN_vkQueueBindSparseImageMemory)(VkQueue queue, VkImage image, uint32_t numBindings, const VkSparseImageMemoryBindInfo* pBindInfo); typedef VkResult (VKAPI *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence); -typedef VkResult (VKAPI *PFN_vkDestroyFence)(VkDevice device, VkFence fence); +typedef void (VKAPI *PFN_vkDestroyFence)(VkDevice device, VkFence fence); typedef VkResult (VKAPI *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences); typedef VkResult (VKAPI *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence); typedef VkResult (VKAPI *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout); typedef VkResult (VKAPI *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, VkSemaphore* pSemaphore); -typedef VkResult (VKAPI *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore); +typedef void (VKAPI *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore); typedef VkResult (VKAPI *PFN_vkQueueSignalSemaphore)(VkQueue queue, VkSemaphore semaphore); typedef VkResult (VKAPI *PFN_vkQueueWaitSemaphore)(VkQueue queue, VkSemaphore semaphore); typedef VkResult (VKAPI *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent); -typedef VkResult (VKAPI *PFN_vkDestroyEvent)(VkDevice device, VkEvent event); +typedef void (VKAPI *PFN_vkDestroyEvent)(VkDevice device, VkEvent event); typedef VkResult (VKAPI *PFN_vkGetEventStatus)(VkDevice device, VkEvent event); typedef VkResult (VKAPI *PFN_vkSetEvent)(VkDevice device, VkEvent event); typedef VkResult (VKAPI *PFN_vkResetEvent)(VkDevice device, VkEvent event); typedef VkResult (VKAPI *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool); -typedef VkResult (VKAPI *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool); +typedef void (VKAPI *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool); typedef VkResult (VKAPI *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, size_t* pDataSize, void* pData, VkQueryResultFlags flags); typedef VkResult (VKAPI *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer); -typedef VkResult (VKAPI *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer); +typedef void (VKAPI *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer); typedef VkResult (VKAPI *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView); -typedef VkResult (VKAPI *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView); +typedef void (VKAPI *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView); typedef VkResult (VKAPI *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage); -typedef VkResult (VKAPI *PFN_vkDestroyImage)(VkDevice device, VkImage image); +typedef void (VKAPI *PFN_vkDestroyImage)(VkDevice device, VkImage image); typedef VkResult (VKAPI *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout); typedef VkResult (VKAPI *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView); -typedef VkResult (VKAPI *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView); -typedef VkResult (VKAPI *PFN_vkCreateAttachmentView)(VkDevice device, const VkAttachmentViewCreateInfo* pCreateInfo, VkAttachmentView* pView); -typedef VkResult (VKAPI *PFN_vkDestroyAttachmentView)(VkDevice device, VkAttachmentView attachmentView); +typedef void (VKAPI *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView); typedef VkResult (VKAPI *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, VkShaderModule* pShaderModule); -typedef VkResult (VKAPI *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule); +typedef void (VKAPI *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule); typedef VkResult (VKAPI *PFN_vkCreateShader)(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader); -typedef VkResult (VKAPI *PFN_vkDestroyShader)(VkDevice device, VkShader shader); +typedef void (VKAPI *PFN_vkDestroyShader)(VkDevice device, VkShader shader); typedef VkResult (VKAPI *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, VkPipelineCache* pPipelineCache); -typedef VkResult (VKAPI *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache); +typedef void (VKAPI *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache); typedef size_t (VKAPI *PFN_vkGetPipelineCacheSize)(VkDevice device, VkPipelineCache pipelineCache); typedef VkResult (VKAPI *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, void* pData); typedef VkResult (VKAPI *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache destCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches); typedef VkResult (VKAPI *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, const VkGraphicsPipelineCreateInfo* pCreateInfos, VkPipeline* pPipelines); typedef VkResult (VKAPI *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, const VkComputePipelineCreateInfo* pCreateInfos, VkPipeline* pPipelines); -typedef VkResult (VKAPI *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline); +typedef void (VKAPI *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline); typedef VkResult (VKAPI *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout); -typedef VkResult (VKAPI *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout); +typedef void (VKAPI *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout); typedef VkResult (VKAPI *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler); -typedef VkResult (VKAPI *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler); +typedef void (VKAPI *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler); typedef VkResult (VKAPI *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout); -typedef VkResult (VKAPI *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout); -typedef VkResult (VKAPI *PFN_vkCreateDescriptorPool)(VkDevice device, VkDescriptorPoolUsage poolUsage, uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool); -typedef VkResult (VKAPI *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool); +typedef void (VKAPI *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout); +typedef VkResult (VKAPI *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool); +typedef void (VKAPI *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool); typedef VkResult (VKAPI *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool); -typedef VkResult (VKAPI *PFN_vkAllocDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets, uint32_t* pCount); +typedef VkResult (VKAPI *PFN_vkAllocDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets); typedef VkResult (VKAPI *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets); -typedef VkResult (VKAPI *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies); -typedef VkResult (VKAPI *PFN_vkCreateDynamicViewportState)(VkDevice device, const VkDynamicViewportStateCreateInfo* pCreateInfo, VkDynamicViewportState* pState); -typedef VkResult (VKAPI *PFN_vkDestroyDynamicViewportState)(VkDevice device, VkDynamicViewportState dynamicViewportState); -typedef VkResult (VKAPI *PFN_vkCreateDynamicRasterState)(VkDevice device, const VkDynamicRasterStateCreateInfo* pCreateInfo, VkDynamicRasterState* pState); -typedef VkResult (VKAPI *PFN_vkDestroyDynamicRasterState)(VkDevice device, VkDynamicRasterState dynamicRasterState); -typedef VkResult (VKAPI *PFN_vkCreateDynamicColorBlendState)(VkDevice device, const VkDynamicColorBlendStateCreateInfo* pCreateInfo, VkDynamicColorBlendState* pState); -typedef VkResult (VKAPI *PFN_vkDestroyDynamicColorBlendState)(VkDevice device, VkDynamicColorBlendState dynamicColorBlendState); -typedef VkResult (VKAPI *PFN_vkCreateDynamicDepthStencilState)(VkDevice device, const VkDynamicDepthStencilStateCreateInfo* pCreateInfo, VkDynamicDepthStencilState* pState); -typedef VkResult (VKAPI *PFN_vkDestroyDynamicDepthStencilState)(VkDevice device, VkDynamicDepthStencilState dynamicDepthStencilState); +typedef void (VKAPI *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies); typedef VkResult (VKAPI *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer); -typedef VkResult (VKAPI *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer); +typedef void (VKAPI *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer); typedef VkResult (VKAPI *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass); -typedef VkResult (VKAPI *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass); +typedef void (VKAPI *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass); typedef VkResult (VKAPI *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity); typedef VkResult (VKAPI *PFN_vkCreateCommandPool)(VkDevice device, const VkCmdPoolCreateInfo* pCreateInfo, VkCmdPool* pCmdPool); -typedef VkResult (VKAPI *PFN_vkDestroyCommandPool)(VkDevice device, VkCmdPool cmdPool); +typedef void (VKAPI *PFN_vkDestroyCommandPool)(VkDevice device, VkCmdPool cmdPool); typedef VkResult (VKAPI *PFN_vkResetCommandPool)(VkDevice device, VkCmdPool cmdPool, VkCmdPoolResetFlags flags); typedef VkResult (VKAPI *PFN_vkCreateCommandBuffer)(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer); -typedef VkResult (VKAPI *PFN_vkDestroyCommandBuffer)(VkDevice device, VkCmdBuffer commandBuffer); +typedef void (VKAPI *PFN_vkDestroyCommandBuffer)(VkDevice device, VkCmdBuffer commandBuffer); typedef VkResult (VKAPI *PFN_vkBeginCommandBuffer)(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo); typedef VkResult (VKAPI *PFN_vkEndCommandBuffer)(VkCmdBuffer cmdBuffer); typedef VkResult (VKAPI *PFN_vkResetCommandBuffer)(VkCmdBuffer cmdBuffer, VkCmdBufferResetFlags flags); typedef void (VKAPI *PFN_vkCmdBindPipeline)(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); -typedef void (VKAPI *PFN_vkCmdBindDynamicViewportState)(VkCmdBuffer cmdBuffer, VkDynamicViewportState dynamicViewportState); -typedef void (VKAPI *PFN_vkCmdBindDynamicRasterState)(VkCmdBuffer cmdBuffer, VkDynamicRasterState dynamicRasterState); -typedef void (VKAPI *PFN_vkCmdBindDynamicColorBlendState)(VkCmdBuffer cmdBuffer, VkDynamicColorBlendState dynamicColorBlendState); -typedef void (VKAPI *PFN_vkCmdBindDynamicDepthStencilState)(VkCmdBuffer cmdBuffer, VkDynamicDepthStencilState dynamicDepthStencilState); +typedef void (VKAPI *PFN_vkCmdSetViewport)(VkCmdBuffer cmdBuffer, uint32_t viewportCount, const VkViewport* pViewports); +typedef void (VKAPI *PFN_vkCmdSetScissor)(VkCmdBuffer cmdBuffer, uint32_t scissorCount, const VkRect2D* pScissors); +typedef void (VKAPI *PFN_vkCmdSetLineWidth)(VkCmdBuffer cmdBuffer, float lineWidth); +typedef void (VKAPI *PFN_vkCmdSetDepthBias)(VkCmdBuffer cmdBuffer, float depthBias, float depthBiasClamp, float slopeScaledDepthBias); +typedef void (VKAPI *PFN_vkCmdSetBlendConstants)(VkCmdBuffer cmdBuffer, const float blendConst[4]); +typedef void (VKAPI *PFN_vkCmdSetDepthBounds)(VkCmdBuffer cmdBuffer, float minDepthBounds, float maxDepthBounds); +typedef void (VKAPI *PFN_vkCmdSetStencilCompareMask)(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilCompareMask); +typedef void (VKAPI *PFN_vkCmdSetStencilWriteMask)(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilWriteMask); +typedef void (VKAPI *PFN_vkCmdSetStencilReference)(VkCmdBuffer cmdBuffer, VkStencilFaceFlags faceMask, uint32_t stencilReference); typedef void (VKAPI *PFN_vkCmdBindDescriptorSets)(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets); typedef void (VKAPI *PFN_vkCmdBindIndexBuffer)(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); typedef void (VKAPI *PFN_vkCmdBindVertexBuffers)(VkCmdBuffer cmdBuffer, uint32_t startBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets); -typedef void (VKAPI *PFN_vkCmdDraw)(VkCmdBuffer cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount); -typedef void (VKAPI *PFN_vkCmdDrawIndexed)(VkCmdBuffer cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount); +typedef void (VKAPI *PFN_vkCmdDraw)(VkCmdBuffer cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +typedef void (VKAPI *PFN_vkCmdDrawIndexed)(VkCmdBuffer cmdBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance); typedef void (VKAPI *PFN_vkCmdDrawIndirect)(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride); typedef void (VKAPI *PFN_vkCmdDrawIndexedIndirect)(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride); typedef void (VKAPI *PFN_vkCmdDispatch)(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z); @@ -2213,9 +2222,9 @@ typedef void (VKAPI *PFN_vkCmdCopyImageToBuffer)(VkCmdBuffer cmdBuffer, VkImage typedef void (VKAPI *PFN_vkCmdUpdateBuffer)(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData); typedef void (VKAPI *PFN_vkCmdFillBuffer)(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data); typedef void (VKAPI *PFN_vkCmdClearColorImage)(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); -typedef void (VKAPI *PFN_vkCmdClearDepthStencilImage)(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, float depth, uint32_t stencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); +typedef void (VKAPI *PFN_vkCmdClearDepthStencilImage)(VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); typedef void (VKAPI *PFN_vkCmdClearColorAttachment)(VkCmdBuffer cmdBuffer, uint32_t colorAttachment, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rectCount, const VkRect3D* pRects); -typedef void (VKAPI *PFN_vkCmdClearDepthStencilAttachment)(VkCmdBuffer cmdBuffer, VkImageAspectFlags imageAspectMask, VkImageLayout imageLayout, float depth, uint32_t stencil, uint32_t rectCount, const VkRect3D* pRects); +typedef void (VKAPI *PFN_vkCmdClearDepthStencilAttachment)(VkCmdBuffer cmdBuffer, VkImageAspectFlags aspectMask, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rectCount, const VkRect3D* pRects); typedef void (VKAPI *PFN_vkCmdResolveImage)(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions); typedef void (VKAPI *PFN_vkCmdSetEvent)(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask); typedef void (VKAPI *PFN_vkCmdResetEvent)(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask); @@ -2237,7 +2246,7 @@ VkResult VKAPI vkCreateInstance( const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance); -VkResult VKAPI vkDestroyInstance( +void VKAPI vkDestroyInstance( VkInstance instance); VkResult VKAPI vkEnumeratePhysicalDevices( @@ -2260,24 +2269,17 @@ VkResult VKAPI vkGetPhysicalDeviceImageFormatProperties( VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, + VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties); -VkResult VKAPI vkGetPhysicalDeviceLimits( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceLimits* pLimits); - VkResult VKAPI vkGetPhysicalDeviceProperties( VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); -VkResult VKAPI vkGetPhysicalDeviceQueueCount( +VkResult VKAPI vkGetPhysicalDeviceQueueFamilyProperties( VkPhysicalDevice physicalDevice, - uint32_t* pCount); - -VkResult VKAPI vkGetPhysicalDeviceQueueProperties( - VkPhysicalDevice physicalDevice, - uint32_t count, - VkPhysicalDeviceQueueProperties* pQueueProperties); + uint32_t* pCount, + VkQueueFamilyProperties* pQueueFamilyProperties); VkResult VKAPI vkGetPhysicalDeviceMemoryProperties( VkPhysicalDevice physicalDevice, @@ -2296,25 +2298,25 @@ VkResult VKAPI vkCreateDevice( const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice); -VkResult VKAPI vkDestroyDevice( +void VKAPI vkDestroyDevice( VkDevice device); -VkResult VKAPI vkGetGlobalExtensionProperties( +VkResult VKAPI vkEnumerateInstanceExtensionProperties( const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties); -VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( +VkResult VKAPI vkEnumerateDeviceExtensionProperties( VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties); -VkResult VKAPI vkGetGlobalLayerProperties( +VkResult VKAPI vkEnumerateInstanceLayerProperties( uint32_t* pCount, VkLayerProperties* pProperties); -VkResult VKAPI vkGetPhysicalDeviceLayerProperties( +VkResult VKAPI vkEnumerateDeviceLayerProperties( VkPhysicalDevice physicalDevice, uint32_t* pCount, VkLayerProperties* pProperties); @@ -2342,7 +2344,7 @@ VkResult VKAPI vkAllocMemory( const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem); -VkResult VKAPI vkFreeMemory( +void VKAPI vkFreeMemory( VkDevice device, VkDeviceMemory mem); @@ -2354,7 +2356,7 @@ VkResult VKAPI vkMapMemory( VkMemoryMapFlags flags, void** ppData); -VkResult VKAPI vkUnmapMemory( +void VKAPI vkUnmapMemory( VkDevice device, VkDeviceMemory mem); @@ -2434,7 +2436,7 @@ VkResult VKAPI vkCreateFence( const VkFenceCreateInfo* pCreateInfo, VkFence* pFence); -VkResult VKAPI vkDestroyFence( +void VKAPI vkDestroyFence( VkDevice device, VkFence fence); @@ -2459,7 +2461,7 @@ VkResult VKAPI vkCreateSemaphore( const VkSemaphoreCreateInfo* pCreateInfo, VkSemaphore* pSemaphore); -VkResult VKAPI vkDestroySemaphore( +void VKAPI vkDestroySemaphore( VkDevice device, VkSemaphore semaphore); @@ -2476,7 +2478,7 @@ VkResult VKAPI vkCreateEvent( const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent); -VkResult VKAPI vkDestroyEvent( +void VKAPI vkDestroyEvent( VkDevice device, VkEvent event); @@ -2497,7 +2499,7 @@ VkResult VKAPI vkCreateQueryPool( const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool); -VkResult VKAPI vkDestroyQueryPool( +void VKAPI vkDestroyQueryPool( VkDevice device, VkQueryPool queryPool); @@ -2515,7 +2517,7 @@ VkResult VKAPI vkCreateBuffer( const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer); -VkResult VKAPI vkDestroyBuffer( +void VKAPI vkDestroyBuffer( VkDevice device, VkBuffer buffer); @@ -2524,7 +2526,7 @@ VkResult VKAPI vkCreateBufferView( const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView); -VkResult VKAPI vkDestroyBufferView( +void VKAPI vkDestroyBufferView( VkDevice device, VkBufferView bufferView); @@ -2533,7 +2535,7 @@ VkResult VKAPI vkCreateImage( const VkImageCreateInfo* pCreateInfo, VkImage* pImage); -VkResult VKAPI vkDestroyImage( +void VKAPI vkDestroyImage( VkDevice device, VkImage image); @@ -2548,25 +2550,16 @@ VkResult VKAPI vkCreateImageView( const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView); -VkResult VKAPI vkDestroyImageView( +void VKAPI vkDestroyImageView( VkDevice device, VkImageView imageView); -VkResult VKAPI vkCreateAttachmentView( - VkDevice device, - const VkAttachmentViewCreateInfo* pCreateInfo, - VkAttachmentView* pView); - -VkResult VKAPI vkDestroyAttachmentView( - VkDevice device, - VkAttachmentView attachmentView); - VkResult VKAPI vkCreateShaderModule( VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, VkShaderModule* pShaderModule); -VkResult VKAPI vkDestroyShaderModule( +void VKAPI vkDestroyShaderModule( VkDevice device, VkShaderModule shaderModule); @@ -2575,7 +2568,7 @@ VkResult VKAPI vkCreateShader( const VkShaderCreateInfo* pCreateInfo, VkShader* pShader); -VkResult VKAPI vkDestroyShader( +void VKAPI vkDestroyShader( VkDevice device, VkShader shader); @@ -2584,7 +2577,7 @@ VkResult VKAPI vkCreatePipelineCache( const VkPipelineCacheCreateInfo* pCreateInfo, VkPipelineCache* pPipelineCache); -VkResult VKAPI vkDestroyPipelineCache( +void VKAPI vkDestroyPipelineCache( VkDevice device, VkPipelineCache pipelineCache); @@ -2617,7 +2610,7 @@ VkResult VKAPI vkCreateComputePipelines( const VkComputePipelineCreateInfo* pCreateInfos, VkPipeline* pPipelines); -VkResult VKAPI vkDestroyPipeline( +void VKAPI vkDestroyPipeline( VkDevice device, VkPipeline pipeline); @@ -2626,7 +2619,7 @@ VkResult VKAPI vkCreatePipelineLayout( const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout); -VkResult VKAPI vkDestroyPipelineLayout( +void VKAPI vkDestroyPipelineLayout( VkDevice device, VkPipelineLayout pipelineLayout); @@ -2635,7 +2628,7 @@ VkResult VKAPI vkCreateSampler( const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler); -VkResult VKAPI vkDestroySampler( +void VKAPI vkDestroySampler( VkDevice device, VkSampler sampler); @@ -2644,18 +2637,16 @@ VkResult VKAPI vkCreateDescriptorSetLayout( const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout); -VkResult VKAPI vkDestroyDescriptorSetLayout( +void VKAPI vkDestroyDescriptorSetLayout( VkDevice device, VkDescriptorSetLayout descriptorSetLayout); VkResult VKAPI vkCreateDescriptorPool( VkDevice device, - VkDescriptorPoolUsage poolUsage, - uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool); -VkResult VKAPI vkDestroyDescriptorPool( +void VKAPI vkDestroyDescriptorPool( VkDevice device, VkDescriptorPool descriptorPool); @@ -2669,8 +2660,7 @@ VkResult VKAPI vkAllocDescriptorSets( VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, - VkDescriptorSet* pDescriptorSets, - uint32_t* pCount); + VkDescriptorSet* pDescriptorSets); VkResult VKAPI vkFreeDescriptorSets( VkDevice device, @@ -2678,55 +2668,19 @@ VkResult VKAPI vkFreeDescriptorSets( uint32_t count, const VkDescriptorSet* pDescriptorSets); -VkResult VKAPI vkUpdateDescriptorSets( +void VKAPI vkUpdateDescriptorSets( VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies); -VkResult VKAPI vkCreateDynamicViewportState( - VkDevice device, - const VkDynamicViewportStateCreateInfo* pCreateInfo, - VkDynamicViewportState* pState); - -VkResult VKAPI vkDestroyDynamicViewportState( - VkDevice device, - VkDynamicViewportState dynamicViewportState); - -VkResult VKAPI vkCreateDynamicRasterState( - VkDevice device, - const VkDynamicRasterStateCreateInfo* pCreateInfo, - VkDynamicRasterState* pState); - -VkResult VKAPI vkDestroyDynamicRasterState( - VkDevice device, - VkDynamicRasterState dynamicRasterState); - -VkResult VKAPI vkCreateDynamicColorBlendState( - VkDevice device, - const VkDynamicColorBlendStateCreateInfo* pCreateInfo, - VkDynamicColorBlendState* pState); - -VkResult VKAPI vkDestroyDynamicColorBlendState( - VkDevice device, - VkDynamicColorBlendState dynamicColorBlendState); - -VkResult VKAPI vkCreateDynamicDepthStencilState( - VkDevice device, - const VkDynamicDepthStencilStateCreateInfo* pCreateInfo, - VkDynamicDepthStencilState* pState); - -VkResult VKAPI vkDestroyDynamicDepthStencilState( - VkDevice device, - VkDynamicDepthStencilState dynamicDepthStencilState); - VkResult VKAPI vkCreateFramebuffer( VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer); -VkResult VKAPI vkDestroyFramebuffer( +void VKAPI vkDestroyFramebuffer( VkDevice device, VkFramebuffer framebuffer); @@ -2735,7 +2689,7 @@ VkResult VKAPI vkCreateRenderPass( const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass); -VkResult VKAPI vkDestroyRenderPass( +void VKAPI vkDestroyRenderPass( VkDevice device, VkRenderPass renderPass); @@ -2749,7 +2703,7 @@ VkResult VKAPI vkCreateCommandPool( const VkCmdPoolCreateInfo* pCreateInfo, VkCmdPool* pCmdPool); -VkResult VKAPI vkDestroyCommandPool( +void VKAPI vkDestroyCommandPool( VkDevice device, VkCmdPool cmdPool); @@ -2763,7 +2717,7 @@ VkResult VKAPI vkCreateCommandBuffer( const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer); -VkResult VKAPI vkDestroyCommandBuffer( +void VKAPI vkDestroyCommandBuffer( VkDevice device, VkCmdBuffer commandBuffer); @@ -2783,21 +2737,49 @@ void VKAPI vkCmdBindPipeline( VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); -void VKAPI vkCmdBindDynamicViewportState( +void VKAPI vkCmdSetViewport( + VkCmdBuffer cmdBuffer, + uint32_t viewportCount, + const VkViewport* pViewports); + +void VKAPI vkCmdSetScissor( + VkCmdBuffer cmdBuffer, + uint32_t scissorCount, + const VkRect2D* pScissors); + +void VKAPI vkCmdSetLineWidth( + VkCmdBuffer cmdBuffer, + float lineWidth); + +void VKAPI vkCmdSetDepthBias( VkCmdBuffer cmdBuffer, - VkDynamicViewportState dynamicViewportState); + float depthBias, + float depthBiasClamp, + float slopeScaledDepthBias); -void VKAPI vkCmdBindDynamicRasterState( +void VKAPI vkCmdSetBlendConstants( VkCmdBuffer cmdBuffer, - VkDynamicRasterState dynamicRasterState); + const float blendConst[4]); -void VKAPI vkCmdBindDynamicColorBlendState( +void VKAPI vkCmdSetDepthBounds( VkCmdBuffer cmdBuffer, - VkDynamicColorBlendState dynamicColorBlendState); + float minDepthBounds, + float maxDepthBounds); -void VKAPI vkCmdBindDynamicDepthStencilState( +void VKAPI vkCmdSetStencilCompareMask( VkCmdBuffer cmdBuffer, - VkDynamicDepthStencilState dynamicDepthStencilState); + VkStencilFaceFlags faceMask, + uint32_t stencilCompareMask); + +void VKAPI vkCmdSetStencilWriteMask( + VkCmdBuffer cmdBuffer, + VkStencilFaceFlags faceMask, + uint32_t stencilWriteMask); + +void VKAPI vkCmdSetStencilReference( + VkCmdBuffer cmdBuffer, + VkStencilFaceFlags faceMask, + uint32_t stencilReference); void VKAPI vkCmdBindDescriptorSets( VkCmdBuffer cmdBuffer, @@ -2824,18 +2806,18 @@ void VKAPI vkCmdBindVertexBuffers( void VKAPI vkCmdDraw( VkCmdBuffer cmdBuffer, - uint32_t firstVertex, uint32_t vertexCount, - uint32_t firstInstance, - uint32_t instanceCount); + uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance); void VKAPI vkCmdDrawIndexed( VkCmdBuffer cmdBuffer, - uint32_t firstIndex, uint32_t indexCount, + uint32_t instanceCount, + uint32_t firstIndex, int32_t vertexOffset, - uint32_t firstInstance, - uint32_t instanceCount); + uint32_t firstInstance); void VKAPI vkCmdDrawIndirect( VkCmdBuffer cmdBuffer, @@ -2930,8 +2912,7 @@ void VKAPI vkCmdClearDepthStencilImage( VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, - float depth, - uint32_t stencil, + const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); @@ -2945,10 +2926,9 @@ void VKAPI vkCmdClearColorAttachment( void VKAPI vkCmdClearDepthStencilAttachment( VkCmdBuffer cmdBuffer, - VkImageAspectFlags imageAspectMask, + VkImageAspectFlags aspectMask, VkImageLayout imageLayout, - float depth, - uint32_t stencil, + const VkClearDepthStencilValue* pDepthStencil, uint32_t rectCount, const VkRect3D* pRects); diff --git a/src/glsl/nir/spirv.h b/src/glsl/nir/spirv.h index d289c687c76..e9e53973801 100644 --- a/src/glsl/nir/spirv.h +++ b/src/glsl/nir/spirv.h @@ -1,20 +1,20 @@ /* ** Copyright (c) 2014-2015 The Khronos Group Inc. -** +** ** Permission is hereby granted, free of charge, to any person obtaining a copy ** of this software and/or associated documentation files (the "Materials"), ** to deal in the Materials without restriction, including without limitation ** the rights to use, copy, modify, merge, publish, distribute, sublicense, ** and/or sell copies of the Materials, and to permit persons to whom the ** Materials are furnished to do so, subject to the following conditions: -** +** ** The above copyright notice and this permission notice shall be included in ** all copies or substantial portions of the Materials. -** +** ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ -** +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -30,16 +30,16 @@ */ /* -** Specification revision 31. +** Specification revision 33. ** Enumeration tokens for SPIR-V, in various styles: ** C, C++, C++11, JSON, Lua, Python -** +** ** - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL ** - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL ** - C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL ** - Lua will use tables, e.g.: spv.SourceLanguage.GLSL ** - Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL'] -** +** ** Some tokens act like mask values, which can be OR'd together, ** while others are mutually exclusive. The mask-like ones have ** "Mask" in their name, and a parallel enum that has the shift @@ -53,7 +53,7 @@ typedef unsigned int SpvId; static const unsigned int SpvMagicNumber = 0x07230203; static const unsigned int SpvVersion = 99; -static const unsigned int SpvRevision = 31; +static const unsigned int SpvRevision = 33; static const unsigned int SpvOpCodeMask = 0xffff; static const unsigned int SpvWordCountShift = 16; @@ -100,7 +100,6 @@ typedef enum SpvExecutionMode_ { SpvExecutionModePointMode = 10, SpvExecutionModeXfb = 11, SpvExecutionModeDepthReplacing = 12, - SpvExecutionModeDepthAny = 13, SpvExecutionModeDepthGreater = 14, SpvExecutionModeDepthLess = 15, SpvExecutionModeDepthUnchanged = 16, @@ -119,6 +118,7 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeOutputTriangleStrip = 29, SpvExecutionModeVecTypeHint = 30, SpvExecutionModeContractionOff = 31, + SpvExecutionModeIndependentForwardProgress = 32, } SpvExecutionMode; typedef enum SpvStorageClass_ { @@ -131,6 +131,7 @@ typedef enum SpvStorageClass_ { SpvStorageClassPrivateGlobal = 6, SpvStorageClassFunction = 7, SpvStorageClassGeneric = 8, + SpvStorageClassPushConstant = 9, SpvStorageClassAtomicCounter = 10, SpvStorageClassImage = 11, } SpvStorageClass; @@ -142,6 +143,7 @@ typedef enum SpvDim_ { SpvDimCube = 3, SpvDimRect = 4, SpvDimBuffer = 5, + SpvDimInputTarget = 6, } SpvDim; typedef enum SpvSamplerAddressingMode_ { @@ -249,6 +251,7 @@ typedef enum SpvImageOperandsShift_ { SpvImageOperandsOffsetShift = 4, SpvImageOperandsConstOffsetsShift = 5, SpvImageOperandsSampleShift = 6, + SpvImageOperandsMinLodShift = 7, } SpvImageOperandsShift; typedef enum SpvImageOperandsMask_ { @@ -260,6 +263,7 @@ typedef enum SpvImageOperandsMask_ { SpvImageOperandsOffsetMask = 0x00000010, SpvImageOperandsConstOffsetsMask = 0x00000020, SpvImageOperandsSampleMask = 0x00000040, + SpvImageOperandsMinLodMask = 0x00000080, } SpvImageOperandsMask; typedef enum SpvFPFastMathModeShift_ { @@ -322,7 +326,7 @@ typedef enum SpvDecoration_ { SpvDecorationCPacked = 10, SpvDecorationBuiltIn = 11, SpvDecorationSmooth = 12, - SpvDecorationNoperspective = 13, + SpvDecorationNoPerspective = 13, SpvDecorationFlat = 14, SpvDecorationPatch = 15, SpvDecorationCentroid = 16, @@ -333,10 +337,9 @@ typedef enum SpvDecoration_ { SpvDecorationVolatile = 21, SpvDecorationConstant = 22, SpvDecorationCoherent = 23, - SpvDecorationNonwritable = 24, - SpvDecorationNonreadable = 25, + SpvDecorationNonWritable = 24, + SpvDecorationNonReadable = 25, SpvDecorationUniform = 26, - SpvDecorationNoStaticUse = 27, SpvDecorationSaturatedConversion = 28, SpvDecorationStream = 29, SpvDecorationLocation = 30, @@ -351,6 +354,9 @@ typedef enum SpvDecoration_ { SpvDecorationFPRoundingMode = 39, SpvDecorationFPFastMathMode = 40, SpvDecorationLinkageAttributes = 41, + SpvDecorationNoContraction = 42, + SpvDecorationInputTargetIndex = 43, + SpvDecorationAlignment = 44, } SpvDecoration; typedef enum SpvBuiltIn_ { @@ -395,6 +401,8 @@ typedef enum SpvBuiltIn_ { SpvBuiltInNumEnqueuedSubgroups = 39, SpvBuiltInSubgroupId = 40, SpvBuiltInSubgroupLocalInvocationId = 41, + SpvBuiltInVertexIndex = 42, + SpvBuiltInInstanceIndex = 43, } SpvBuiltIn; typedef enum SpvSelectionControlShift_ { @@ -435,41 +443,43 @@ typedef enum SpvFunctionControlMask_ { } SpvFunctionControlMask; typedef enum SpvMemorySemanticsShift_ { - SpvMemorySemanticsRelaxedShift = 0, - SpvMemorySemanticsSequentiallyConsistentShift = 1, - SpvMemorySemanticsAcquireShift = 2, - SpvMemorySemanticsReleaseShift = 3, - SpvMemorySemanticsUniformMemoryShift = 4, - SpvMemorySemanticsSubgroupMemoryShift = 5, - SpvMemorySemanticsWorkgroupLocalMemoryShift = 6, - SpvMemorySemanticsWorkgroupGlobalMemoryShift = 7, - SpvMemorySemanticsAtomicCounterMemoryShift = 8, - SpvMemorySemanticsImageMemoryShift = 9, + SpvMemorySemanticsAcquireShift = 1, + SpvMemorySemanticsReleaseShift = 2, + SpvMemorySemanticsAcquireReleaseShift = 3, + SpvMemorySemanticsSequentiallyConsistentShift = 4, + SpvMemorySemanticsUniformMemoryShift = 6, + SpvMemorySemanticsSubgroupMemoryShift = 7, + SpvMemorySemanticsWorkgroupLocalMemoryShift = 8, + SpvMemorySemanticsWorkgroupGlobalMemoryShift = 9, + SpvMemorySemanticsAtomicCounterMemoryShift = 10, + SpvMemorySemanticsImageMemoryShift = 11, } SpvMemorySemanticsShift; typedef enum SpvMemorySemanticsMask_ { SpvMemorySemanticsMaskNone = 0, - SpvMemorySemanticsRelaxedMask = 0x00000001, - SpvMemorySemanticsSequentiallyConsistentMask = 0x00000002, - SpvMemorySemanticsAcquireMask = 0x00000004, - SpvMemorySemanticsReleaseMask = 0x00000008, - SpvMemorySemanticsUniformMemoryMask = 0x00000010, - SpvMemorySemanticsSubgroupMemoryMask = 0x00000020, - SpvMemorySemanticsWorkgroupLocalMemoryMask = 0x00000040, - SpvMemorySemanticsWorkgroupGlobalMemoryMask = 0x00000080, - SpvMemorySemanticsAtomicCounterMemoryMask = 0x00000100, - SpvMemorySemanticsImageMemoryMask = 0x00000200, + SpvMemorySemanticsAcquireMask = 0x00000002, + SpvMemorySemanticsReleaseMask = 0x00000004, + SpvMemorySemanticsAcquireReleaseMask = 0x00000008, + SpvMemorySemanticsSequentiallyConsistentMask = 0x00000010, + SpvMemorySemanticsUniformMemoryMask = 0x00000040, + SpvMemorySemanticsSubgroupMemoryMask = 0x00000080, + SpvMemorySemanticsWorkgroupLocalMemoryMask = 0x00000100, + SpvMemorySemanticsWorkgroupGlobalMemoryMask = 0x00000200, + SpvMemorySemanticsAtomicCounterMemoryMask = 0x00000400, + SpvMemorySemanticsImageMemoryMask = 0x00000800, } SpvMemorySemanticsMask; typedef enum SpvMemoryAccessShift_ { SpvMemoryAccessVolatileShift = 0, SpvMemoryAccessAlignedShift = 1, + SpvMemoryAccessNontemporalShift = 2, } SpvMemoryAccessShift; typedef enum SpvMemoryAccessMask_ { SpvMemoryAccessMaskNone = 0, SpvMemoryAccessVolatileMask = 0x00000001, SpvMemoryAccessAlignedMask = 0x00000002, + SpvMemoryAccessNontemporalMask = 0x00000004, } SpvMemoryAccessMask; typedef enum SpvScope_ { @@ -538,11 +548,30 @@ typedef enum SpvCapability_ { SpvCapabilityCullDistance = 33, SpvCapabilityImageCubeArray = 34, SpvCapabilitySampleRateShading = 35, + SpvCapabilityImageRect = 36, + SpvCapabilitySampledRect = 37, + SpvCapabilityGenericPointer = 38, + SpvCapabilityInt8 = 39, + SpvCapabilityInputTarget = 40, + SpvCapabilitySparseResidency = 41, + SpvCapabilityMinLod = 42, + SpvCapabilitySampled1D = 43, + SpvCapabilityImage1D = 44, + SpvCapabilitySampledCubeArray = 45, + SpvCapabilitySampledBuffer = 46, + SpvCapabilityImageBuffer = 47, + SpvCapabilityImageMSArray = 48, + SpvCapabilityAdvancedFormats = 49, + SpvCapabilityImageQuery = 50, + SpvCapabilityDerivativeControl = 51, + SpvCapabilityInterpolationFunction = 52, + SpvCapabilityTransformFeedback = 53, } SpvCapability; typedef enum SpvOp_ { SpvOpNop = 0, SpvOpUndef = 1, + SpvOpSourceContinued = 2, SpvOpSource = 3, SpvOpSourceExtension = 4, SpvOpName = 5, @@ -576,6 +605,7 @@ typedef enum SpvOp_ { SpvOpTypeReserveId = 36, SpvOpTypeQueue = 37, SpvOpTypePipe = 38, + SpvOpTypeForwardPointer = 39, SpvOpConstantTrue = 41, SpvOpConstantFalse = 42, SpvOpConstant = 43, @@ -602,6 +632,7 @@ typedef enum SpvOp_ { SpvOpPtrAccessChain = 67, SpvOpArrayLength = 68, SpvOpGenericPtrMemSemantics = 69, + SpvOpInBoundsPtrAccessChain = 70, SpvOpDecorate = 71, SpvOpMemberDecorate = 72, SpvOpDecorationGroup = 73, @@ -629,7 +660,6 @@ typedef enum SpvOp_ { SpvOpImageDrefGather = 97, SpvOpImageRead = 98, SpvOpImageWrite = 99, - SpvOpImageQueryDim = 100, SpvOpImageQueryFormat = 101, SpvOpImageQueryOrder = 102, SpvOpImageQuerySizeLod = 103, @@ -678,7 +708,8 @@ typedef enum SpvOp_ { SpvOpDot = 148, SpvOpIAddCarry = 149, SpvOpISubBorrow = 150, - SpvOpIMulExtended = 151, + SpvOpUMulExtended = 151, + SpvOpSMulExtended = 152, SpvOpAny = 154, SpvOpAll = 155, SpvOpIsNan = 156, @@ -815,6 +846,22 @@ typedef enum SpvOp_ { SpvOpCaptureEventProfilingInfo = 302, SpvOpGetDefaultQueue = 303, SpvOpBuildNDRange = 304, + SpvOpImageSparseSampleImplicitLod = 305, + SpvOpImageSparseSampleExplicitLod = 306, + SpvOpImageSparseSampleDrefImplicitLod = 307, + SpvOpImageSparseSampleDrefExplicitLod = 308, + SpvOpImageSparseSampleProjImplicitLod = 309, + SpvOpImageSparseSampleProjExplicitLod = 310, + SpvOpImageSparseSampleProjDrefImplicitLod = 311, + SpvOpImageSparseSampleProjDrefExplicitLod = 312, + SpvOpImageSparseFetch = 313, + SpvOpImageSparseGather = 314, + SpvOpImageSparseDrefGather = 315, + SpvOpImageSparseTexelsResident = 316, + SpvOpNoLine = 317, + SpvOpAtomicFlagTestAndSet = 318, + SpvOpAtomicFlagClear = 319, } SpvOp; #endif // #ifndef spirv_H + diff --git a/src/glsl/nir/spirv_glsl450.h b/src/glsl/nir/spirv_glsl450.h index d828b152f43..d1c9b5c1d44 100644 --- a/src/glsl/nir/spirv_glsl450.h +++ b/src/glsl/nir/spirv_glsl450.h @@ -13,7 +13,7 @@ ** ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -28,7 +28,7 @@ #define GLSLstd450_H const int GLSLstd450Version = 99; -const int GLSLstd450Revision = 2; +const int GLSLstd450Revision = 3; enum GLSLstd450 { GLSLstd450Bad = 0, // Don't use @@ -82,47 +82,44 @@ enum GLSLstd450 { GLSLstd450FClamp = 43, GLSLstd450UClamp = 44, GLSLstd450SClamp = 45, - GLSLstd450Mix = 46, - GLSLstd450Step = 47, - GLSLstd450SmoothStep = 48, - - GLSLstd450Fma = 49, - GLSLstd450Frexp = 50, // second operand needs an OpVariable to write to - GLSLstd450FrexpStruct = 51, // no OpVariable operand - GLSLstd450Ldexp = 52, - - GLSLstd450PackSnorm4x8 = 53, - GLSLstd450PackUnorm4x8 = 54, - GLSLstd450PackSnorm2x16 = 55, - GLSLstd450PackUnorm2x16 = 56, - GLSLstd450PackHalf2x16 = 57, - GLSLstd450PackDouble2x32 = 58, - GLSLstd450UnpackSnorm2x16 = 59, - GLSLstd450UnpackUnorm2x16 = 60, - GLSLstd450UnpackHalf2x16 = 61, - GLSLstd450UnpackSnorm4x8 = 62, - GLSLstd450UnpackUnorm4x8 = 63, - GLSLstd450UnpackDouble2x32 = 64, - - GLSLstd450Length = 65, - GLSLstd450Distance = 66, - GLSLstd450Cross = 67, - GLSLstd450Normalize = 68, - GLSLstd450FaceForward = 69, - GLSLstd450Reflect = 70, - GLSLstd450Refract = 71, - - GLSLstd450FindILSB = 72, - GLSLstd450FindSMSB = 73, - GLSLstd450FindUMSB = 74, - - GLSLstd450InterpolateAtCentroid = 75, - GLSLstd450InterpolateAtSample = 76, - GLSLstd450InterpolateAtOffset = 77, - - GLSLstd450AddCarry = 78, // These three should move to the core instruction set - GLSLstd450SubBorrow = 79, - GLSLstd450MulExtended = 80, + GLSLstd450FMix = 46, + GLSLstd450IMix = 47, + GLSLstd450Step = 48, + GLSLstd450SmoothStep = 49, + + GLSLstd450Fma = 50, + GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to + GLSLstd450FrexpStruct = 52, // no OpVariable operand + GLSLstd450Ldexp = 53, + + GLSLstd450PackSnorm4x8 = 54, + GLSLstd450PackUnorm4x8 = 55, + GLSLstd450PackSnorm2x16 = 56, + GLSLstd450PackUnorm2x16 = 57, + GLSLstd450PackHalf2x16 = 58, + GLSLstd450PackDouble2x32 = 59, + GLSLstd450UnpackSnorm2x16 = 60, + GLSLstd450UnpackUnorm2x16 = 61, + GLSLstd450UnpackHalf2x16 = 62, + GLSLstd450UnpackSnorm4x8 = 63, + GLSLstd450UnpackUnorm4x8 = 64, + GLSLstd450UnpackDouble2x32 = 65, + + GLSLstd450Length = 66, + GLSLstd450Distance = 67, + GLSLstd450Cross = 68, + GLSLstd450Normalize = 69, + GLSLstd450FaceForward = 70, + GLSLstd450Reflect = 71, + GLSLstd450Refract = 72, + + GLSLstd450FindILsb = 73, + GLSLstd450FindSMsb = 74, + GLSLstd450FindUMsb = 75, + + GLSLstd450InterpolateAtCentroid = 76, + GLSLstd450InterpolateAtSample = 77, + GLSLstd450InterpolateAtOffset = 78, GLSLstd450Count }; diff --git a/src/glsl/nir/spirv_glsl450_to_nir.c b/src/glsl/nir/spirv_glsl450_to_nir.c index 60bd597820c..1056c0f1ddf 100644 --- a/src/glsl/nir/spirv_glsl450_to_nir.c +++ b/src/glsl/nir/spirv_glsl450_to_nir.c @@ -86,7 +86,7 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, case GLSLstd450Modf: op = nir_op_fmod; break; case GLSLstd450FMin: op = nir_op_fmin; break; case GLSLstd450FMax: op = nir_op_fmax; break; - case GLSLstd450Mix: op = nir_op_flrp; break; + case GLSLstd450FMix: op = nir_op_flrp; break; case GLSLstd450Step: val->ssa->def = nir_sge(&b->nb, src[1], src[0]); return; @@ -116,9 +116,6 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, val->ssa->def = nir_fdiv(&b->nb, src[0], build_length(&b->nb, src[0])); return; - case GLSLstd450AddCarry: op = nir_op_uadd_carry; break; - case GLSLstd450SubBorrow: op = nir_op_usub_borrow; break; - case GLSLstd450Exp: case GLSLstd450Log: case GLSLstd450FClamp: @@ -142,7 +139,7 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint, case GLSLstd450FaceForward: case GLSLstd450Reflect: case GLSLstd450Refract: - case GLSLstd450MulExtended: + case GLSLstd450IMix: default: unreachable("Unhandled opcode"); } diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 45053a6c937..d0fb6a255a5 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -340,7 +340,7 @@ struct_member_decoration_cb(struct vtn_builder *b, case SpvDecorationSmooth: ctx->fields[member].interpolation = INTERP_QUALIFIER_SMOOTH; break; - case SpvDecorationNoperspective: + case SpvDecorationNoPerspective: ctx->fields[member].interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; break; case SpvDecorationFlat: @@ -740,7 +740,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, case SpvDecorationSmooth: var->data.interpolation = INTERP_QUALIFIER_SMOOTH; break; - case SpvDecorationNoperspective: + case SpvDecorationNoPerspective: var->data.interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; break; case SpvDecorationFlat: @@ -759,7 +759,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, assert(var->constant_initializer != NULL); var->data.read_only = true; break; - case SpvDecorationNonwritable: + case SpvDecorationNonWritable: var->data.read_only = true; break; case SpvDecorationLocation: @@ -790,9 +790,6 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, b->builtins[dec->literals[0]] = var; break; } - case SpvDecorationNoStaticUse: - /* This can safely be ignored */ - break; case SpvDecorationRowMajor: case SpvDecorationColMajor: case SpvDecorationGLSLShared: @@ -801,7 +798,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, case SpvDecorationAliased: case SpvDecorationVolatile: case SpvDecorationCoherent: - case SpvDecorationNonreadable: + case SpvDecorationNonReadable: case SpvDecorationUniform: /* This is really nice but we have no use for it right now. */ case SpvDecorationCPacked: @@ -1511,7 +1508,7 @@ static nir_tex_src vtn_tex_src(struct vtn_builder *b, unsigned index, nir_tex_src_type type) { nir_tex_src src; - src.src = nir_src_for_ssa(vtn_value(b, index, vtn_value_type_ssa)->ssa->def); + src.src = nir_src_for_ssa(vtn_ssa_value(b, index)->def); src.src_type = type; return src; } @@ -1571,16 +1568,19 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, nir_texop texop; switch (opcode) { case SpvOpImageSampleImplicitLod: - case SpvOpImageSampleExplicitLod: case SpvOpImageSampleDrefImplicitLod: - case SpvOpImageSampleDrefExplicitLod: case SpvOpImageSampleProjImplicitLod: - case SpvOpImageSampleProjExplicitLod: case SpvOpImageSampleProjDrefImplicitLod: - case SpvOpImageSampleProjDrefExplicitLod: texop = nir_texop_tex; break; + case SpvOpImageSampleExplicitLod: + case SpvOpImageSampleDrefExplicitLod: + case SpvOpImageSampleProjExplicitLod: + case SpvOpImageSampleProjDrefExplicitLod: + texop = nir_texop_txl; + break; + case SpvOpImageFetch: texop = nir_texop_txf; break; @@ -1619,8 +1619,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, } if (operands & SpvImageOperandsLodMask) { - assert(texop == nir_texop_tex); - texop = nir_texop_txl; + assert(texop == nir_texop_txl || texop == nir_texop_txf || + texop == nir_texop_txs); (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_lod); } diff --git a/src/vulkan/Makefile.am b/src/vulkan/Makefile.am index eebe54d9475..0d0abd27300 100644 --- a/src/vulkan/Makefile.am +++ b/src/vulkan/Makefile.am @@ -51,11 +51,11 @@ AM_CPPFLAGS = \ -I$(top_builddir)/src/vulkan libvulkan_la_CFLAGS = \ - -Wall -Wextra -Wno-unused-parameter -fvisibility=hidden -O0 -g \ + -Wall -Wno-unused-parameter -fvisibility=hidden -O0 -g \ -Wstrict-prototypes -Wmissing-prototypes -Wno-override-init libvulkan_la_CXXFLAGS = \ - -Wall -Wextra -Wno-unused-parameter -fvisibility=hidden -O0 -g + -Wall -Wno-unused-parameter -fvisibility=hidden -O0 -g VULKAN_SOURCES = \ anv_allocator.c \ diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index c74d6d0eb17..28d9dd9d694 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -38,25 +38,91 @@ * is concerned, most of anv_cmd_buffer is magic. */ +/* TODO: These are taken from GLES. We should check the Vulkan spec */ +const struct anv_dynamic_state default_dynamic_state = { + .viewport = { + .count = 0, + }, + .scissor = { + .count = 0, + }, + .line_width = 1.0f, + .depth_bias = { + .bias = 0.0f, + .clamp = 0.0f, + .slope_scaled = 0.0f, + }, + .blend_constants = { 0.0f, 0.0f, 0.0f, 0.0f }, + .depth_bounds = { + .min = 0.0f, + .max = 1.0f, + }, + .stencil_compare_mask = { + .front = ~0u, + .back = ~0u, + }, + .stencil_write_mask = { + .front = ~0u, + .back = ~0u, + }, + .stencil_reference = { + .front = 0u, + .back = 0u, + }, +}; + +void +anv_dynamic_state_copy(struct anv_dynamic_state *dest, + const struct anv_dynamic_state *src, + uint32_t copy_mask) +{ + if (copy_mask & (1 << VK_DYNAMIC_STATE_VIEWPORT)) { + dest->viewport.count = src->viewport.count; + typed_memcpy(dest->viewport.viewports, src->viewport.viewports, + src->viewport.count); + } + + if (copy_mask & (1 << VK_DYNAMIC_STATE_SCISSOR)) { + dest->scissor.count = src->scissor.count; + typed_memcpy(dest->scissor.scissors, src->scissor.scissors, + src->scissor.count); + } + + if (copy_mask & (1 << VK_DYNAMIC_STATE_LINE_WIDTH)) + dest->line_width = src->line_width; + + if (copy_mask & (1 << VK_DYNAMIC_STATE_DEPTH_BIAS)) + dest->depth_bias = src->depth_bias; + + if (copy_mask & (1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS)) + typed_memcpy(dest->blend_constants, src->blend_constants, 4); + + if (copy_mask & (1 << VK_DYNAMIC_STATE_DEPTH_BOUNDS)) + dest->depth_bounds = src->depth_bounds; + + if (copy_mask & (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK)) + dest->stencil_compare_mask = src->stencil_compare_mask; + + if (copy_mask & (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK)) + dest->stencil_write_mask = src->stencil_write_mask; + + if (copy_mask & (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE)) + dest->stencil_reference = src->stencil_reference; +} + static void anv_cmd_state_init(struct anv_cmd_state *state) { - state->rs_state = NULL; - state->vp_state = NULL; - state->cb_state = NULL; - state->ds_state = NULL; memset(&state->state_vf, 0, sizeof(state->state_vf)); memset(&state->descriptors, 0, sizeof(state->descriptors)); memset(&state->push_constants, 0, sizeof(state->push_constants)); - state->dirty = 0; + state->dirty = ~0; state->vb_dirty = 0; state->descriptors_dirty = 0; state->push_constants_dirty = 0; state->pipeline = NULL; - state->vp_state = NULL; - state->rs_state = NULL; - state->ds_state = NULL; + state->dynamic = default_dynamic_state; state->gen7.index_buffer = NULL; } @@ -144,7 +210,7 @@ VkResult anv_CreateCommandBuffer( return result; } -VkResult anv_DestroyCommandBuffer( +void anv_DestroyCommandBuffer( VkDevice _device, VkCmdBuffer _cmd_buffer) { @@ -158,8 +224,6 @@ VkResult anv_DestroyCommandBuffer( anv_state_stream_finish(&cmd_buffer->surface_state_stream); anv_state_stream_finish(&cmd_buffer->dynamic_state_stream); anv_device_free(device, cmd_buffer); - - return VK_SUCCESS; } VkResult anv_ResetCommandBuffer( @@ -202,9 +266,10 @@ VkResult anv_BeginCommandBuffer( cmd_buffer->state.pass = anv_render_pass_from_handle(pBeginInfo->renderPass); - /* FIXME: We shouldn't be starting on the first subpass */ - anv_cmd_buffer_begin_subpass(cmd_buffer, - &cmd_buffer->state.pass->subpasses[0]); + struct anv_subpass *subpass = + &cmd_buffer->state.pass->subpasses[pBeginInfo->subpass]; + + anv_cmd_buffer_begin_subpass(cmd_buffer, subpass); } anv_cmd_buffer_emit_state_base_address(cmd_buffer); @@ -254,6 +319,12 @@ void anv_CmdBindPipeline( cmd_buffer->state.vb_dirty |= pipeline->vb_used; cmd_buffer->state.dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY; cmd_buffer->state.push_constants_dirty |= pipeline->active_stages; + + /* Apply the dynamic state from the pipeline */ + cmd_buffer->state.dirty |= pipeline->dynamic_state_mask; + anv_dynamic_state_copy(&cmd_buffer->state.dynamic, + &pipeline->dynamic_state, + pipeline->dynamic_state_mask); break; default: @@ -262,48 +333,128 @@ void anv_CmdBindPipeline( } } -void anv_CmdBindDynamicViewportState( +void anv_CmdSetViewport( VkCmdBuffer cmdBuffer, - VkDynamicViewportState dynamicViewportState) + uint32_t viewportCount, + const VkViewport* pViewports) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); - ANV_FROM_HANDLE(anv_dynamic_vp_state, vp_state, dynamicViewportState); - cmd_buffer->state.vp_state = vp_state; - cmd_buffer->state.dirty |= ANV_CMD_BUFFER_VP_DIRTY; + cmd_buffer->state.dynamic.viewport.count = viewportCount; + memcpy(cmd_buffer->state.dynamic.viewport.viewports, + pViewports, viewportCount * sizeof(*pViewports)); + + cmd_buffer->state.dirty |= ANV_DYNAMIC_VIEWPORT_DIRTY; } -void anv_CmdBindDynamicRasterState( +void anv_CmdSetScissor( VkCmdBuffer cmdBuffer, - VkDynamicRasterState dynamicRasterState) + uint32_t scissorCount, + const VkRect2D* pScissors) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); - ANV_FROM_HANDLE(anv_dynamic_rs_state, rs_state, dynamicRasterState); - cmd_buffer->state.rs_state = rs_state; - cmd_buffer->state.dirty |= ANV_CMD_BUFFER_RS_DIRTY; + cmd_buffer->state.dynamic.scissor.count = scissorCount; + memcpy(cmd_buffer->state.dynamic.scissor.scissors, + pScissors, scissorCount * sizeof(*pScissors)); + + cmd_buffer->state.dirty |= ANV_DYNAMIC_SCISSOR_DIRTY; } -void anv_CmdBindDynamicColorBlendState( +void anv_CmdSetLineWidth( VkCmdBuffer cmdBuffer, - VkDynamicColorBlendState dynamicColorBlendState) + float lineWidth) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); - ANV_FROM_HANDLE(anv_dynamic_cb_state, cb_state, dynamicColorBlendState); - cmd_buffer->state.cb_state = cb_state; - cmd_buffer->state.dirty |= ANV_CMD_BUFFER_CB_DIRTY; + cmd_buffer->state.dynamic.line_width = lineWidth; + + cmd_buffer->state.dirty |= ANV_DYNAMIC_LINE_WIDTH_DIRTY; } -void anv_CmdBindDynamicDepthStencilState( +void anv_CmdSetDepthBias( VkCmdBuffer cmdBuffer, - VkDynamicDepthStencilState dynamicDepthStencilState) + float depthBias, + float depthBiasClamp, + float slopeScaledDepthBias) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); - ANV_FROM_HANDLE(anv_dynamic_ds_state, ds_state, dynamicDepthStencilState); - cmd_buffer->state.ds_state = ds_state; - cmd_buffer->state.dirty |= ANV_CMD_BUFFER_DS_DIRTY; + cmd_buffer->state.dynamic.depth_bias.bias = depthBias; + cmd_buffer->state.dynamic.depth_bias.clamp = depthBiasClamp; + cmd_buffer->state.dynamic.depth_bias.slope_scaled = slopeScaledDepthBias; + + cmd_buffer->state.dirty |= ANV_DYNAMIC_DEPTH_BIAS_DIRTY; +} + +void anv_CmdSetBlendConstants( + VkCmdBuffer cmdBuffer, + const float blendConst[4]) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + + memcpy(cmd_buffer->state.dynamic.blend_constants, + blendConst, sizeof(float) * 4); + + cmd_buffer->state.dirty |= ANV_DYNAMIC_BLEND_CONSTANTS_DIRTY; +} + +void anv_CmdSetDepthBounds( + VkCmdBuffer cmdBuffer, + float minDepthBounds, + float maxDepthBounds) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + + cmd_buffer->state.dynamic.depth_bounds.min = minDepthBounds; + cmd_buffer->state.dynamic.depth_bounds.max = maxDepthBounds; + + cmd_buffer->state.dirty |= ANV_DYNAMIC_DEPTH_BOUNDS_DIRTY; +} + +void anv_CmdSetStencilCompareMask( + VkCmdBuffer cmdBuffer, + VkStencilFaceFlags faceMask, + uint32_t stencilCompareMask) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + + if (faceMask & VK_STENCIL_FACE_FRONT_BIT) + cmd_buffer->state.dynamic.stencil_compare_mask.front = stencilCompareMask; + if (faceMask & VK_STENCIL_FACE_BACK_BIT) + cmd_buffer->state.dynamic.stencil_compare_mask.back = stencilCompareMask; + + cmd_buffer->state.dirty |= ANV_DYNAMIC_STENCIL_COMPARE_MASK_DIRTY; +} + +void anv_CmdSetStencilWriteMask( + VkCmdBuffer cmdBuffer, + VkStencilFaceFlags faceMask, + uint32_t stencilWriteMask) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + + if (faceMask & VK_STENCIL_FACE_FRONT_BIT) + cmd_buffer->state.dynamic.stencil_write_mask.front = stencilWriteMask; + if (faceMask & VK_STENCIL_FACE_BACK_BIT) + cmd_buffer->state.dynamic.stencil_write_mask.back = stencilWriteMask; + + cmd_buffer->state.dirty |= ANV_DYNAMIC_STENCIL_WRITE_MASK_DIRTY; +} + +void anv_CmdSetStencilReference( + VkCmdBuffer cmdBuffer, + VkStencilFaceFlags faceMask, + uint32_t stencilReference) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + + if (faceMask & VK_STENCIL_FACE_FRONT_BIT) + cmd_buffer->state.dynamic.stencil_reference.front = stencilReference; + if (faceMask & VK_STENCIL_FACE_BACK_BIT) + cmd_buffer->state.dynamic.stencil_reference.back = stencilReference; + + cmd_buffer->state.dirty |= ANV_DYNAMIC_STENCIL_REFERENCE_DIRTY; } void anv_CmdBindDescriptorSets( @@ -333,7 +484,7 @@ void anv_CmdBindDescriptorSets( } if (set_layout->num_dynamic_buffers > 0) { - uint32_t s; + VkShaderStage s; for_each_bit(s, set_layout->shader_stages) { anv_cmd_buffer_ensure_push_constant_field(cmd_buffer, s, dynamic_offsets); @@ -389,7 +540,7 @@ add_surface_state_reloc(struct anv_cmd_buffer *cmd_buffer, VkResult anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, - unsigned stage, struct anv_state *bt_state) + VkShaderStage stage, struct anv_state *bt_state) { struct anv_framebuffer *fb = cmd_buffer->state.framebuffer; struct anv_subpass *subpass = cmd_buffer->state.subpass; @@ -432,16 +583,12 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, * put the color attachments into the binding table. */ for (uint32_t a = 0; a < attachments; a++) { - const struct anv_attachment_view *attachment = + const struct anv_image_view *iview = fb->attachments[subpass->color_attachments[a]]; - assert(attachment->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR); - const struct anv_color_attachment_view *view = - (const struct anv_color_attachment_view *)attachment; - - bt_map[a] = view->view.surface_state.offset + state_offset; - add_surface_state_reloc(cmd_buffer, view->view.surface_state, - view->view.bo, view->view.offset); + bt_map[a] = iview->color_rt_surface_state.offset + state_offset; + add_surface_state_reloc(cmd_buffer, iview->color_rt_surface_state, + iview->bo, iview->offset); } if (layout == NULL) @@ -456,15 +603,31 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, uint32_t start = bias + layout->set[set].stage[stage].surface_start; for (uint32_t b = 0; b < set_layout->stage[stage].surface_count; b++) { - struct anv_surface_view *view = - d->set->descriptors[surface_slots[b].index].view; + struct anv_descriptor *desc = + &d->set->descriptors[surface_slots[b].index]; - if (!view) + const struct anv_state *surface_state; + struct anv_bo *bo; + uint32_t bo_offset; + + switch (desc->type) { + case ANV_DESCRIPTOR_TYPE_EMPTY: + case ANV_DESCRIPTOR_TYPE_SAMPLER: continue; + case ANV_DESCRIPTOR_TYPE_BUFFER_VIEW: + surface_state = &desc->buffer_view->surface_state; + bo = desc->buffer_view->bo; + bo_offset = desc->buffer_view->offset; + break; + case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW: + surface_state = &desc->image_view->nonrt_surface_state; + bo = desc->image_view->bo; + bo_offset = desc->image_view->offset; + break; + } - bt_map[start + b] = view->surface_state.offset + state_offset; - add_surface_state_reloc(cmd_buffer, view->surface_state, - view->bo, view->offset); + bt_map[start + b] = surface_state->offset + state_offset; + add_surface_state_reloc(cmd_buffer, *surface_state, bo, bo_offset); } } @@ -473,7 +636,7 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, VkResult anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer, - unsigned stage, struct anv_state *state) + VkShaderStage stage, struct anv_state *state) { struct anv_pipeline_layout *layout; uint32_t sampler_count; @@ -502,12 +665,14 @@ anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer, uint32_t start = layout->set[set].stage[stage].sampler_start; for (uint32_t b = 0; b < set_layout->stage[stage].sampler_count; b++) { - struct anv_sampler *sampler = - d->set->descriptors[sampler_slots[b].index].sampler; + struct anv_descriptor *desc = + &d->set->descriptors[sampler_slots[b].index]; - if (!sampler) + if (desc->type != ANV_DESCRIPTOR_TYPE_SAMPLER) continue; + struct anv_sampler *sampler = desc->sampler; + memcpy(state->map + (start + b) * 16, sampler->state, sizeof(sampler->state)); } @@ -517,7 +682,7 @@ anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer, } static VkResult -flush_descriptor_set(struct anv_cmd_buffer *cmd_buffer, uint32_t stage) +flush_descriptor_set(struct anv_cmd_buffer *cmd_buffer, VkShaderStage stage) { struct anv_state surfaces = { 0, }, samplers = { 0, }; VkResult result; @@ -567,8 +732,9 @@ flush_descriptor_set(struct anv_cmd_buffer *cmd_buffer, uint32_t stage) void anv_flush_descriptor_sets(struct anv_cmd_buffer *cmd_buffer) { - uint32_t s, dirty = cmd_buffer->state.descriptors_dirty & - cmd_buffer->state.pipeline->active_stages; + VkShaderStage s; + VkShaderStageFlags dirty = cmd_buffer->state.descriptors_dirty & + cmd_buffer->state.pipeline->active_stages; VkResult result = VK_SUCCESS; for_each_bit(s, dirty) { @@ -650,6 +816,148 @@ anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer, } } +static void +emit_viewport_state(struct anv_cmd_buffer *cmd_buffer, + uint32_t count, const VkViewport *viewports) +{ + struct anv_state sf_clip_state = + anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 64, 64); + struct anv_state cc_state = + anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 8, 32); + + for (uint32_t i = 0; i < count; i++) { + const VkViewport *vp = &viewports[i]; + + /* The gen7 state struct has just the matrix and guardband fields, the + * gen8 struct adds the min/max viewport fields. */ + struct GEN8_SF_CLIP_VIEWPORT sf_clip_viewport = { + .ViewportMatrixElementm00 = vp->width / 2, + .ViewportMatrixElementm11 = vp->height / 2, + .ViewportMatrixElementm22 = (vp->maxDepth - vp->minDepth) / 2, + .ViewportMatrixElementm30 = vp->originX + vp->width / 2, + .ViewportMatrixElementm31 = vp->originY + vp->height / 2, + .ViewportMatrixElementm32 = (vp->maxDepth + vp->minDepth) / 2, + .XMinClipGuardband = -1.0f, + .XMaxClipGuardband = 1.0f, + .YMinClipGuardband = -1.0f, + .YMaxClipGuardband = 1.0f, + .XMinViewPort = vp->originX, + .XMaxViewPort = vp->originX + vp->width - 1, + .YMinViewPort = vp->originY, + .YMaxViewPort = vp->originY + vp->height - 1, + }; + + struct GEN7_CC_VIEWPORT cc_viewport = { + .MinimumDepth = vp->minDepth, + .MaximumDepth = vp->maxDepth + }; + + GEN8_SF_CLIP_VIEWPORT_pack(NULL, sf_clip_state.map + i * 64, + &sf_clip_viewport); + GEN7_CC_VIEWPORT_pack(NULL, cc_state.map + i * 32, &cc_viewport); + } + + anv_batch_emit(&cmd_buffer->batch, + GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_CC, + .CCViewportPointer = cc_state.offset); + anv_batch_emit(&cmd_buffer->batch, + GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, + .SFClipViewportPointer = sf_clip_state.offset); +} + +void +anv_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer) +{ + if (cmd_buffer->state.dynamic.viewport.count > 0) { + emit_viewport_state(cmd_buffer, cmd_buffer->state.dynamic.viewport.count, + cmd_buffer->state.dynamic.viewport.viewports); + } else { + /* If viewport count is 0, this is taken to mean "use the default" */ + emit_viewport_state(cmd_buffer, 1, + &(VkViewport) { + .originX = 0.0f, + .originY = 0.0f, + .width = cmd_buffer->state.framebuffer->width, + .height = cmd_buffer->state.framebuffer->height, + .minDepth = 0.0f, + .maxDepth = 1.0f, + }); + } +} + +static inline int64_t +clamp_int64(int64_t x, int64_t min, int64_t max) +{ + if (x < min) + return min; + else if (x < max) + return x; + else + return max; +} + +static void +emit_scissor_state(struct anv_cmd_buffer *cmd_buffer, + uint32_t count, const VkRect2D *scissors) +{ + struct anv_state scissor_state = + anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 32, 32); + + for (uint32_t i = 0; i < count; i++) { + const VkRect2D *s = &scissors[i]; + + /* Since xmax and ymax are inclusive, we have to have xmax < xmin or + * ymax < ymin for empty clips. In case clip x, y, width height are all + * 0, the clamps below produce 0 for xmin, ymin, xmax, ymax, which isn't + * what we want. Just special case empty clips and produce a canonical + * empty clip. */ + static const struct GEN7_SCISSOR_RECT empty_scissor = { + .ScissorRectangleYMin = 1, + .ScissorRectangleXMin = 1, + .ScissorRectangleYMax = 0, + .ScissorRectangleXMax = 0 + }; + + const int max = 0xffff; + struct GEN7_SCISSOR_RECT scissor = { + /* Do this math using int64_t so overflow gets clamped correctly. */ + .ScissorRectangleYMin = clamp_int64(s->offset.y, 0, max), + .ScissorRectangleXMin = clamp_int64(s->offset.x, 0, max), + .ScissorRectangleYMax = clamp_int64((uint64_t) s->offset.y + s->extent.height - 1, 0, max), + .ScissorRectangleXMax = clamp_int64((uint64_t) s->offset.x + s->extent.width - 1, 0, max) + }; + + if (s->extent.width <= 0 || s->extent.height <= 0) { + GEN7_SCISSOR_RECT_pack(NULL, scissor_state.map + i * 32, + &empty_scissor); + } else { + GEN7_SCISSOR_RECT_pack(NULL, scissor_state.map + i * 32, &scissor); + } + } + + anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_SCISSOR_STATE_POINTERS, + .ScissorRectPointer = scissor_state.offset); +} + +void +anv_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer) +{ + if (cmd_buffer->state.dynamic.scissor.count > 0) { + emit_scissor_state(cmd_buffer, cmd_buffer->state.dynamic.scissor.count, + cmd_buffer->state.dynamic.scissor.scissors); + } else { + /* Emit a default scissor based on the currently bound framebuffer */ + emit_scissor_state(cmd_buffer, 1, + &(VkRect2D) { + .offset = { .x = 0, .y = 0, }, + .extent = { + .width = cmd_buffer->state.framebuffer->width, + .height = cmd_buffer->state.framebuffer->height, + }, + }); + } +} + void anv_CmdSetEvent( VkCmdBuffer cmdBuffer, VkEvent event, @@ -715,7 +1023,7 @@ void anv_CmdPushConstants( const void* values) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); - uint32_t stage; + VkShaderStage stage; for_each_bit(stage, stageFlags) { anv_cmd_buffer_ensure_push_constant_field(cmd_buffer, stage, client_data); @@ -767,7 +1075,7 @@ VkResult anv_CreateCommandPool( return VK_SUCCESS; } -VkResult anv_DestroyCommandPool( +void anv_DestroyCommandPool( VkDevice _device, VkCmdPool cmdPool) { @@ -777,8 +1085,6 @@ VkResult anv_DestroyCommandPool( anv_ResetCommandPool(_device, cmdPool, 0); anv_device_free(device, pool); - - return VK_SUCCESS; } VkResult anv_ResetCommandPool( @@ -799,7 +1105,7 @@ VkResult anv_ResetCommandPool( /** * Return NULL if the current subpass has no depthstencil attachment. */ -const struct anv_depth_stencil_view * +const struct anv_image_view * anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer) { const struct anv_subpass *subpass = cmd_buffer->state.subpass; @@ -808,10 +1114,10 @@ anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer) if (subpass->depth_stencil_attachment == VK_ATTACHMENT_UNUSED) return NULL; - const struct anv_attachment_view *aview = + const struct anv_image_view *iview = fb->attachments[subpass->depth_stencil_attachment]; - assert(aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL); + assert(anv_format_is_depth_or_stencil(iview->format)); - return (const struct anv_depth_stencil_view *) aview; + return iview; } diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index b6f083b4c83..4e677054afe 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -43,42 +43,49 @@ anv_physical_device_init(struct anv_physical_device *device, fd = open(path, O_RDWR | O_CLOEXEC); if (fd < 0) - return vk_errorf(VK_ERROR_UNAVAILABLE, "failed to open %s: %m", path); + return vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "failed to open %s: %m", path); device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->instance = instance; device->path = path; - + device->chipset_id = anv_gem_get_param(fd, I915_PARAM_CHIPSET_ID); if (!device->chipset_id) { - result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get chipset id: %m"); + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "failed to get chipset id: %m"); goto fail; } device->name = brw_get_device_name(device->chipset_id); device->info = brw_get_device_info(device->chipset_id, -1); if (!device->info) { - result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get device info"); + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "failed to get device info"); goto fail; } if (anv_gem_get_aperture(fd, &device->aperture_size) == -1) { - result = vk_errorf(VK_ERROR_UNAVAILABLE, "failed to get aperture size: %m"); + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "failed to get aperture size: %m"); goto fail; } if (!anv_gem_get_param(fd, I915_PARAM_HAS_WAIT_TIMEOUT)) { - result = vk_errorf(VK_ERROR_UNAVAILABLE, "kernel missing gem wait"); + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "kernel missing gem wait"); goto fail; } if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) { - result = vk_errorf(VK_ERROR_UNAVAILABLE, "kernel missing execbuf2"); + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "kernel missing execbuf2"); goto fail; } if (!anv_gem_get_param(fd, I915_PARAM_HAS_LLC)) { - result = vk_errorf(VK_ERROR_UNAVAILABLE, "non-llc gpu"); + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "non-llc gpu"); goto fail; } @@ -148,7 +155,7 @@ VkResult anv_CreateInstance( } } if (!found) - return vk_error(VK_ERROR_INVALID_EXTENSION); + return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT); } if (pCreateInfo->pAllocCb) { @@ -178,7 +185,7 @@ VkResult anv_CreateInstance( return VK_SUCCESS; } -VkResult anv_DestroyInstance( +void anv_DestroyInstance( VkInstance _instance) { ANV_FROM_HANDLE(anv_instance, instance, _instance); @@ -190,8 +197,6 @@ VkResult anv_DestroyInstance( _mesa_locale_fini(); instance->pfnFree(instance->pAllocUserData, instance); - - return VK_SUCCESS; } void * @@ -280,7 +285,7 @@ VkResult anv_GetPhysicalDeviceFeatures( .sampleRateShading = false, .dualSourceBlend = true, .logicOp = true, - .instancedDrawIndirect = true, + .multiDrawIndirect = true, .depthClip = false, .depthBiasClamp = false, .fillModeNonSolid = true, @@ -290,6 +295,7 @@ VkResult anv_GetPhysicalDeviceFeatures( .textureCompressionETC2 = true, .textureCompressionASTC_LDR = true, .textureCompressionBC = true, + .occlusionQueryNonConservative = false, /* FINISHME */ .pipelineStatisticsQuery = true, .vertexSideEffects = false, .tessellationSideEffects = false, @@ -297,11 +303,9 @@ VkResult anv_GetPhysicalDeviceFeatures( .fragmentSideEffects = false, .shaderTessellationPointSize = false, .shaderGeometryPointSize = true, - .shaderTextureGatherExtended = true, + .shaderImageGatherExtended = true, .shaderStorageImageExtendedFormats = false, .shaderStorageImageMultisample = false, - .shaderStorageBufferArrayConstantIndexing = false, - .shaderStorageImageArrayConstantIndexing = false, .shaderUniformBufferArrayDynamicIndexing = true, .shaderSampledImageArrayDynamicIndexing = false, .shaderStorageBufferArrayDynamicIndexing = false, @@ -310,34 +314,39 @@ VkResult anv_GetPhysicalDeviceFeatures( .shaderCullDistance = false, .shaderFloat64 = false, .shaderInt64 = false, - .shaderFloat16 = false, .shaderInt16 = false, + .alphaToOne = true, }; return VK_SUCCESS; } -VkResult anv_GetPhysicalDeviceLimits( +VkResult anv_GetPhysicalDeviceProperties( VkPhysicalDevice physicalDevice, - VkPhysicalDeviceLimits* pLimits) + VkPhysicalDeviceProperties* pProperties) { - ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice); - const struct brw_device_info *devinfo = physical_device->info; + ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice); + const struct brw_device_info *devinfo = pdevice->info; - anv_finishme("Get correct values for PhysicalDeviceLimits"); + anv_finishme("Get correct values for VkPhysicalDeviceLimits"); - *pLimits = (VkPhysicalDeviceLimits) { + VkPhysicalDeviceLimits limits = { .maxImageDimension1D = (1 << 14), .maxImageDimension2D = (1 << 14), .maxImageDimension3D = (1 << 10), .maxImageDimensionCube = (1 << 14), .maxImageArrayLayers = (1 << 10), + + /* Broadwell supports 1, 2, 4, and 8 samples. */ + .sampleCounts = 4, + .maxTexelBufferSize = (1 << 14), .maxUniformBufferSize = UINT32_MAX, .maxStorageBufferSize = UINT32_MAX, .maxPushConstantsSize = MAX_PUSH_CONSTANTS_SIZE, .maxMemoryAllocationCount = UINT32_MAX, .bufferImageGranularity = 64, /* A cache line */ + .sparseAddressSpaceSize = 0, .maxBoundDescriptorSets = MAX_SETS, .maxDescriptorSets = UINT32_MAX, .maxPerStageDescriptorSamplers = 64, @@ -347,10 +356,13 @@ VkResult anv_GetPhysicalDeviceLimits( .maxPerStageDescriptorStorageImages = 64, .maxDescriptorSetSamplers = 256, .maxDescriptorSetUniformBuffers = 256, + .maxDescriptorSetUniformBuffersDynamic = 256, .maxDescriptorSetStorageBuffers = 256, + .maxDescriptorSetStorageBuffersDynamic = 256, .maxDescriptorSetSampledImages = 256, .maxDescriptorSetStorageImages = 256, .maxVertexInputAttributes = 32, + .maxVertexInputBindings = 32, .maxVertexInputAttributeOffset = 256, .maxVertexInputBindingStride = 256, .maxVertexOutputComponents = 32, @@ -391,8 +403,7 @@ VkResult anv_GetPhysicalDeviceLimits( .primitiveRestartForPatches = UINT32_MAX, .maxSamplerLodBias = 16, .maxSamplerAnisotropy = 16, - .maxViewports = 16, - .maxDynamicViewportStates = UINT32_MAX, + .maxViewports = MAX_VIEWPORTS, .maxViewportDimensions = { (1 << 14), (1 << 14) }, .viewportBoundsRange = { -1.0, 1.0 }, /* FIXME */ .viewportSubPixelBits = 13, /* We take a float? */ @@ -429,21 +440,14 @@ VkResult anv_GetPhysicalDeviceLimits( .lineWidthGranularity = (1.0 / 128.0), }; - return VK_SUCCESS; -} - -VkResult anv_GetPhysicalDeviceProperties( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties* pProperties) -{ - ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice); - *pProperties = (VkPhysicalDeviceProperties) { .apiVersion = VK_MAKE_VERSION(0, 138, 1), .driverVersion = 1, .vendorId = 0x8086, .deviceId = pdevice->chipset_id, .deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, + .limits = limits, + .sparseProperties = {0}, /* Broadwell doesn't do sparse. */ }; strcpy(pProperties->deviceName, pdevice->name); @@ -453,23 +457,18 @@ VkResult anv_GetPhysicalDeviceProperties( return VK_SUCCESS; } -VkResult anv_GetPhysicalDeviceQueueCount( +VkResult anv_GetPhysicalDeviceQueueFamilyProperties( VkPhysicalDevice physicalDevice, - uint32_t* pCount) + uint32_t* pCount, + VkQueueFamilyProperties* pQueueFamilyProperties) { - *pCount = 1; + if (pQueueFamilyProperties == NULL) { + *pCount = 1; + } - return VK_SUCCESS; -} + assert(*pCount >= 1); -VkResult anv_GetPhysicalDeviceQueueProperties( - VkPhysicalDevice physicalDevice, - uint32_t count, - VkPhysicalDeviceQueueProperties* pQueueProperties) -{ - assert(count == 1); - - *pQueueProperties = (VkPhysicalDeviceQueueProperties) { + *pQueueFamilyProperties = (VkQueueFamilyProperties) { .queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_DMA_BIT, @@ -502,7 +501,7 @@ VkResult anv_GetPhysicalDeviceMemoryProperties( pMemoryProperties->memoryHeapCount = 1; pMemoryProperties->memoryHeaps[0] = (VkMemoryHeap) { .size = heap_size, - .flags = VK_MEMORY_HEAP_HOST_LOCAL, + .flags = VK_MEMORY_HEAP_HOST_LOCAL_BIT, }; return VK_SUCCESS; @@ -554,12 +553,12 @@ static void anv_device_init_border_colors(struct anv_device *device) { 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 } }, + [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 } }, + [VK_BORDER_COLOR_INT_TRANSPARENT_BLACK] = { .uint32 = { 0, 0, 0, 0 } }, + [VK_BORDER_COLOR_INT_OPAQUE_BLACK] = { .uint32 = { 0, 0, 0, 1 } }, + [VK_BORDER_COLOR_INT_OPAQUE_WHITE] = { .uint32 = { 1, 1, 1, 1 } }, }; device->border_colors = @@ -589,7 +588,7 @@ VkResult anv_CreateDevice( } } if (!found) - return vk_error(VK_ERROR_INVALID_EXTENSION); + return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT); } anv_set_dispatch_gen(physical_device->info->gen); @@ -647,10 +646,10 @@ VkResult anv_CreateDevice( fail_device: anv_device_free(device, device); - return vk_error(VK_ERROR_UNAVAILABLE); + return vk_error(VK_ERROR_INITIALIZATION_FAILED); } -VkResult anv_DestroyDevice( +void anv_DestroyDevice( VkDevice _device) { ANV_FROM_HANDLE(anv_device, device, _device); @@ -679,11 +678,9 @@ VkResult anv_DestroyDevice( close(device->fd); anv_instance_free(device->instance, device); - - return VK_SUCCESS; } -VkResult anv_GetGlobalExtensionProperties( +VkResult anv_EnumerateInstanceExtensionProperties( const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties) @@ -701,7 +698,7 @@ VkResult anv_GetGlobalExtensionProperties( return VK_SUCCESS; } -VkResult anv_GetPhysicalDeviceExtensionProperties( +VkResult anv_EnumerateDeviceExtensionProperties( VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pCount, @@ -720,7 +717,7 @@ VkResult anv_GetPhysicalDeviceExtensionProperties( return VK_SUCCESS; } -VkResult anv_GetGlobalLayerProperties( +VkResult anv_EnumerateInstanceLayerProperties( uint32_t* pCount, VkLayerProperties* pProperties) { @@ -730,10 +727,10 @@ VkResult anv_GetGlobalLayerProperties( } /* None supported at this time */ - return vk_error(VK_ERROR_INVALID_LAYER); + return vk_error(VK_ERROR_LAYER_NOT_PRESENT); } -VkResult anv_GetPhysicalDeviceLayerProperties( +VkResult anv_EnumerateDeviceLayerProperties( VkPhysicalDevice physicalDevice, uint32_t* pCount, VkLayerProperties* pProperties) @@ -744,7 +741,7 @@ VkResult anv_GetPhysicalDeviceLayerProperties( } /* None supported at this time */ - return vk_error(VK_ERROR_INVALID_LAYER); + return vk_error(VK_ERROR_LAYER_NOT_PRESENT); } VkResult anv_GetDeviceQueue( @@ -779,13 +776,19 @@ VkResult anv_QueueSubmit( assert(cmd_buffer->level == VK_CMD_BUFFER_LEVEL_PRIMARY); ret = anv_gem_execbuffer(device, &cmd_buffer->execbuf2.execbuf); - if (ret != 0) - return vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m"); + if (ret != 0) { + /* We don't know the real error. */ + return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, + "execbuf2 failed: %m"); + } if (fence) { ret = anv_gem_execbuffer(device, &fence->execbuf); - if (ret != 0) - return vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m"); + if (ret != 0) { + /* We don't know the real error. */ + return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, + "execbuf2 failed: %m"); + } } for (uint32_t i = 0; i < cmd_buffer->execbuf2.bo_count; i++) @@ -848,14 +851,16 @@ VkResult anv_DeviceWaitIdle( ret = anv_gem_execbuffer(device, &execbuf); if (ret != 0) { - result = vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m"); + /* We don't know the real error. */ + result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, "execbuf2 failed: %m"); goto fail; } timeout = INT64_MAX; ret = anv_gem_wait(device, bo->gem_handle, &timeout); if (ret != 0) { - result = vk_errorf(VK_ERROR_UNKNOWN, "execbuf2 failed: %m"); + /* We don't know the real error. */ + result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, "execbuf2 failed: %m"); goto fail; } @@ -911,10 +916,8 @@ VkResult anv_AllocMemory( assert(pAllocInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO); - if (pAllocInfo->memoryTypeIndex != 0) { - /* We support exactly one memory heap. */ - return vk_error(VK_ERROR_INVALID_VALUE); - } + /* We support exactly one memory heap. */ + assert(pAllocInfo->memoryTypeIndex == 0); /* FINISHME: Fail if allocation request exceeds heap size. */ @@ -937,7 +940,7 @@ VkResult anv_AllocMemory( return result; } -VkResult anv_FreeMemory( +void anv_FreeMemory( VkDevice _device, VkDeviceMemory _mem) { @@ -951,8 +954,6 @@ VkResult anv_FreeMemory( anv_gem_close(device, mem->bo.gem_handle); anv_device_free(device, mem); - - return VK_SUCCESS; } VkResult anv_MapMemory( @@ -980,15 +981,13 @@ VkResult anv_MapMemory( return VK_SUCCESS; } -VkResult anv_UnmapMemory( +void anv_UnmapMemory( VkDevice _device, VkDeviceMemory _mem) { ANV_FROM_HANDLE(anv_device_memory, mem, _mem); anv_gem_munmap(mem->map, mem->map_size); - - return VK_SUCCESS; } VkResult anv_FlushMappedMemoryRanges( @@ -1195,7 +1194,7 @@ VkResult anv_CreateFence( return result; } -VkResult anv_DestroyFence( +void anv_DestroyFence( VkDevice _device, VkFence _fence) { @@ -1205,8 +1204,6 @@ VkResult anv_DestroyFence( anv_gem_munmap(fence->bo.map, fence->bo.size); anv_gem_close(device, fence->bo.gem_handle); anv_device_free(device, fence); - - return VK_SUCCESS; } VkResult anv_ResetFences( @@ -1259,10 +1256,13 @@ VkResult anv_WaitForFences( for (uint32_t i = 0; i < fenceCount; i++) { ANV_FROM_HANDLE(anv_fence, fence, pFences[i]); ret = anv_gem_wait(device, fence->bo.gem_handle, &t); - if (ret == -1 && errno == ETIME) + if (ret == -1 && errno == ETIME) { return VK_TIMEOUT; - else if (ret == -1) - return vk_errorf(VK_ERROR_UNKNOWN, "gem wait failed: %m"); + } else if (ret == -1) { + /* We don't know the real error. */ + return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, + "gem wait failed: %m"); + } } return VK_SUCCESS; @@ -1278,11 +1278,11 @@ VkResult anv_CreateSemaphore( stub_return(VK_UNSUPPORTED); } -VkResult anv_DestroySemaphore( +void anv_DestroySemaphore( VkDevice device, VkSemaphore semaphore) { - stub_return(VK_UNSUPPORTED); + stub(); } VkResult anv_QueueSignalSemaphore( @@ -1309,11 +1309,11 @@ VkResult anv_CreateEvent( stub_return(VK_UNSUPPORTED); } -VkResult anv_DestroyEvent( +void anv_DestroyEvent( VkDevice device, VkEvent event) { - stub_return(VK_UNSUPPORTED); + stub(); } VkResult anv_GetEventStatus( @@ -1363,7 +1363,7 @@ VkResult anv_CreateBuffer( return VK_SUCCESS; } -VkResult anv_DestroyBuffer( +void anv_DestroyBuffer( VkDevice _device, VkBuffer _buffer) { @@ -1371,8 +1371,6 @@ VkResult anv_DestroyBuffer( ANV_FROM_HANDLE(anv_buffer, buffer, _buffer); anv_device_free(device, buffer); - - return VK_SUCCESS; } void @@ -1396,19 +1394,19 @@ VkResult anv_buffer_view_create( struct anv_device * device, const VkBufferViewCreateInfo* pCreateInfo, - struct anv_buffer_view ** view_out) + struct anv_buffer_view ** bview_out) { ANV_FROM_HANDLE(anv_buffer, buffer, pCreateInfo->buffer); - struct anv_buffer_view *view; + struct anv_buffer_view *bview; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO); - view = anv_device_alloc(device, sizeof(*view), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (view == NULL) + bview = anv_device_alloc(device, sizeof(*bview), 8, + VK_SYSTEM_ALLOC_TYPE_API_OBJECT); + if (bview == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - view->view = (struct anv_surface_view) { + *bview = (struct anv_buffer_view) { .bo = buffer->bo, .offset = buffer->offset + pCreateInfo->offset, .surface_state = anv_state_pool_alloc(&device->surface_state_pool, 64, 64), @@ -1416,25 +1414,23 @@ anv_buffer_view_create( .range = pCreateInfo->range, }; - *view_out = view; + *bview_out = bview; return VK_SUCCESS; } -VkResult anv_DestroyBufferView( +void anv_DestroyBufferView( VkDevice _device, VkBufferView _bview) { ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_buffer_view, bview, _bview); - anv_surface_view_fini(device, &bview->view); + anv_state_pool_free(&device->surface_state_pool, bview->surface_state); anv_device_free(device, bview); - - return VK_SUCCESS; } -VkResult anv_DestroySampler( +void anv_DestroySampler( VkDevice _device, VkSampler _sampler) { @@ -1442,8 +1438,6 @@ VkResult anv_DestroySampler( ANV_FROM_HANDLE(anv_sampler, sampler, _sampler); anv_device_free(device, sampler); - - return VK_SUCCESS; } // Descriptor set functions @@ -1462,7 +1456,7 @@ VkResult anv_CreateDescriptorSetLayout( uint32_t surface_count[VK_SHADER_STAGE_NUM] = { 0, }; uint32_t num_dynamic_buffers = 0; uint32_t count = 0; - uint32_t stages = 0; + VkShaderStageFlags stages = 0; uint32_t s; for (uint32_t i = 0; i < pCreateInfo->count; i++) { @@ -1601,7 +1595,7 @@ VkResult anv_CreateDescriptorSetLayout( return VK_SUCCESS; } -VkResult anv_DestroyDescriptorSetLayout( +void anv_DestroyDescriptorSetLayout( VkDevice _device, VkDescriptorSetLayout _set_layout) { @@ -1609,14 +1603,10 @@ VkResult anv_DestroyDescriptorSetLayout( ANV_FROM_HANDLE(anv_descriptor_set_layout, set_layout, _set_layout); anv_device_free(device, set_layout); - - return VK_SUCCESS; } VkResult anv_CreateDescriptorPool( VkDevice device, - VkDescriptorPoolUsage poolUsage, - uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool) { @@ -1625,12 +1615,11 @@ VkResult anv_CreateDescriptorPool( return VK_SUCCESS; } -VkResult anv_DestroyDescriptorPool( +void anv_DestroyDescriptorPool( VkDevice _device, VkDescriptorPool _pool) { anv_finishme("VkDescriptorPool is a stub: free the pool's descriptor sets"); - return VK_SUCCESS; } VkResult anv_ResetDescriptorPool( @@ -1676,29 +1665,28 @@ VkResult anv_AllocDescriptorSets( VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, - VkDescriptorSet* pDescriptorSets, - uint32_t* pCount) + VkDescriptorSet* pDescriptorSets) { ANV_FROM_HANDLE(anv_device, device, _device); - VkResult result; + VkResult result = VK_SUCCESS; struct anv_descriptor_set *set; + uint32_t i; - for (uint32_t i = 0; i < count; i++) { + for (i = 0; i < count; i++) { ANV_FROM_HANDLE(anv_descriptor_set_layout, layout, pSetLayouts[i]); result = anv_descriptor_set_create(device, layout, &set); - if (result != VK_SUCCESS) { - *pCount = i; - return result; - } + if (result != VK_SUCCESS) + break; pDescriptorSets[i] = anv_descriptor_set_to_handle(set); } - *pCount = count; + if (result != VK_SUCCESS) + anv_FreeDescriptorSets(_device, descriptorPool, i, pDescriptorSets); - return VK_SUCCESS; + return result; } VkResult anv_FreeDescriptorSets( @@ -1718,7 +1706,7 @@ VkResult anv_FreeDescriptorSets( return VK_SUCCESS; } -VkResult anv_UpdateDescriptorSets( +void anv_UpdateDescriptorSets( VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, @@ -1729,12 +1717,27 @@ VkResult anv_UpdateDescriptorSets( const VkWriteDescriptorSet *write = &pDescriptorWrites[i]; ANV_FROM_HANDLE(anv_descriptor_set, set, write->destSet); + for (uint32_t j = 0; j < write->count; ++j) { + const VkDescriptorBufferInfo *binfo + = &write->pDescriptors[j].bufferInfo; + + if (binfo->buffer.handle || binfo->offset || binfo->range) { + anv_finishme("VkWriteDesciptorSet::bufferInfo"); + break; + } + } + switch (write->descriptorType) { case VK_DESCRIPTOR_TYPE_SAMPLER: case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: for (uint32_t j = 0; j < write->count; j++) { - set->descriptors[write->destBinding + j].sampler = - anv_sampler_from_handle(write->pDescriptors[j].sampler); + ANV_FROM_HANDLE(anv_sampler, sampler, + write->pDescriptors[j].sampler); + + set->descriptors[write->destBinding + j] = (struct anv_descriptor) { + .type = ANV_DESCRIPTOR_TYPE_SAMPLER, + .sampler = sampler, + }; } if (write->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) @@ -1747,7 +1750,11 @@ VkResult anv_UpdateDescriptorSets( for (uint32_t j = 0; j < write->count; j++) { ANV_FROM_HANDLE(anv_image_view, iview, write->pDescriptors[j].imageView); - set->descriptors[write->destBinding + j].view = &iview->view; + + set->descriptors[write->destBinding + j] = (struct anv_descriptor) { + .type = ANV_DESCRIPTOR_TYPE_IMAGE_VIEW, + .image_view = iview, + }; } break; @@ -1767,7 +1774,11 @@ VkResult anv_UpdateDescriptorSets( for (uint32_t j = 0; j < write->count; j++) { ANV_FROM_HANDLE(anv_buffer_view, bview, write->pDescriptors[j].bufferView); - set->descriptors[write->destBinding + j].view = &bview->view; + + set->descriptors[write->destBinding + j] = (struct anv_descriptor) { + .type = ANV_DESCRIPTOR_TYPE_BUFFER_VIEW, + .buffer_view = bview, + }; } default: @@ -1784,189 +1795,6 @@ VkResult anv_UpdateDescriptorSets( src->descriptors[copy->srcBinding + j]; } } - - return VK_SUCCESS; -} - -// State object functions - -static inline int64_t -clamp_int64(int64_t x, int64_t min, int64_t max) -{ - if (x < min) - return min; - else if (x < max) - return x; - else - return max; -} - -VkResult anv_CreateDynamicViewportState( - VkDevice _device, - const VkDynamicViewportStateCreateInfo* pCreateInfo, - VkDynamicViewportState* pState) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_dynamic_vp_state *state; - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_VIEWPORT_STATE_CREATE_INFO); - - state = anv_device_alloc(device, sizeof(*state), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (state == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - unsigned count = pCreateInfo->viewportAndScissorCount; - state->sf_clip_vp = anv_state_pool_alloc(&device->dynamic_state_pool, - count * 64, 64); - state->cc_vp = anv_state_pool_alloc(&device->dynamic_state_pool, - count * 8, 32); - state->scissor = anv_state_pool_alloc(&device->dynamic_state_pool, - count * 32, 32); - - for (uint32_t i = 0; i < pCreateInfo->viewportAndScissorCount; i++) { - const VkViewport *vp = &pCreateInfo->pViewports[i]; - const VkRect2D *s = &pCreateInfo->pScissors[i]; - - /* The gen7 state struct has just the matrix and guardband fields, the - * gen8 struct adds the min/max viewport fields. */ - struct GEN8_SF_CLIP_VIEWPORT sf_clip_viewport = { - .ViewportMatrixElementm00 = vp->width / 2, - .ViewportMatrixElementm11 = vp->height / 2, - .ViewportMatrixElementm22 = (vp->maxDepth - vp->minDepth) / 2, - .ViewportMatrixElementm30 = vp->originX + vp->width / 2, - .ViewportMatrixElementm31 = vp->originY + vp->height / 2, - .ViewportMatrixElementm32 = (vp->maxDepth + vp->minDepth) / 2, - .XMinClipGuardband = -1.0f, - .XMaxClipGuardband = 1.0f, - .YMinClipGuardband = -1.0f, - .YMaxClipGuardband = 1.0f, - .XMinViewPort = vp->originX, - .XMaxViewPort = vp->originX + vp->width - 1, - .YMinViewPort = vp->originY, - .YMaxViewPort = vp->originY + vp->height - 1, - }; - - struct GEN7_CC_VIEWPORT cc_viewport = { - .MinimumDepth = vp->minDepth, - .MaximumDepth = vp->maxDepth - }; - - /* Since xmax and ymax are inclusive, we have to have xmax < xmin or - * ymax < ymin for empty clips. In case clip x, y, width height are all - * 0, the clamps below produce 0 for xmin, ymin, xmax, ymax, which isn't - * what we want. Just special case empty clips and produce a canonical - * empty clip. */ - static const struct GEN7_SCISSOR_RECT empty_scissor = { - .ScissorRectangleYMin = 1, - .ScissorRectangleXMin = 1, - .ScissorRectangleYMax = 0, - .ScissorRectangleXMax = 0 - }; - - const int max = 0xffff; - struct GEN7_SCISSOR_RECT scissor = { - /* Do this math using int64_t so overflow gets clamped correctly. */ - .ScissorRectangleYMin = clamp_int64(s->offset.y, 0, max), - .ScissorRectangleXMin = clamp_int64(s->offset.x, 0, max), - .ScissorRectangleYMax = clamp_int64((uint64_t) s->offset.y + s->extent.height - 1, 0, max), - .ScissorRectangleXMax = clamp_int64((uint64_t) s->offset.x + s->extent.width - 1, 0, max) - }; - - GEN8_SF_CLIP_VIEWPORT_pack(NULL, state->sf_clip_vp.map + i * 64, &sf_clip_viewport); - GEN7_CC_VIEWPORT_pack(NULL, state->cc_vp.map + i * 32, &cc_viewport); - - if (s->extent.width <= 0 || s->extent.height <= 0) { - GEN7_SCISSOR_RECT_pack(NULL, state->scissor.map + i * 32, &empty_scissor); - } else { - GEN7_SCISSOR_RECT_pack(NULL, state->scissor.map + i * 32, &scissor); - } - } - - *pState = anv_dynamic_vp_state_to_handle(state); - - return VK_SUCCESS; -} - -VkResult anv_DestroyDynamicViewportState( - VkDevice _device, - VkDynamicViewportState _vp_state) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_dynamic_vp_state, vp_state, _vp_state); - - anv_state_pool_free(&device->dynamic_state_pool, vp_state->sf_clip_vp); - anv_state_pool_free(&device->dynamic_state_pool, vp_state->cc_vp); - anv_state_pool_free(&device->dynamic_state_pool, vp_state->scissor); - - anv_device_free(device, vp_state); - - return VK_SUCCESS; -} - -VkResult anv_DestroyDynamicRasterState( - VkDevice _device, - VkDynamicRasterState _rs_state) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_dynamic_rs_state, rs_state, _rs_state); - - anv_device_free(device, rs_state); - - return VK_SUCCESS; -} - -VkResult anv_CreateDynamicColorBlendState( - VkDevice _device, - const VkDynamicColorBlendStateCreateInfo* pCreateInfo, - VkDynamicColorBlendState* pState) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_dynamic_cb_state *state; - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_COLOR_BLEND_STATE_CREATE_INFO); - - state = anv_device_alloc(device, sizeof(*state), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (state == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - struct GEN7_COLOR_CALC_STATE color_calc_state = { - .BlendConstantColorRed = pCreateInfo->blendConst[0], - .BlendConstantColorGreen = pCreateInfo->blendConst[1], - .BlendConstantColorBlue = pCreateInfo->blendConst[2], - .BlendConstantColorAlpha = pCreateInfo->blendConst[3] - }; - - GEN7_COLOR_CALC_STATE_pack(NULL, state->color_calc_state, &color_calc_state); - - *pState = anv_dynamic_cb_state_to_handle(state); - - return VK_SUCCESS; -} - -VkResult anv_DestroyDynamicColorBlendState( - VkDevice _device, - VkDynamicColorBlendState _cb_state) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_dynamic_cb_state, cb_state, _cb_state); - - anv_device_free(device, cb_state); - - return VK_SUCCESS; -} - -VkResult anv_DestroyDynamicDepthStencilState( - VkDevice _device, - VkDynamicDepthStencilState _ds_state) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_dynamic_ds_state, ds_state, _ds_state); - - anv_device_free(device, ds_state); - - return VK_SUCCESS; } VkResult anv_CreateFramebuffer( @@ -1980,7 +1808,7 @@ VkResult anv_CreateFramebuffer( assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO); size_t size = sizeof(*framebuffer) + - sizeof(struct anv_attachment_view *) * pCreateInfo->attachmentCount; + sizeof(struct anv_image_view *) * pCreateInfo->attachmentCount; framebuffer = anv_device_alloc(device, size, 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT); if (framebuffer == NULL) @@ -1988,54 +1816,27 @@ VkResult anv_CreateFramebuffer( framebuffer->attachment_count = pCreateInfo->attachmentCount; for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) { - ANV_FROM_HANDLE(anv_attachment_view, view, - pCreateInfo->pAttachments[i].view); - - framebuffer->attachments[i] = view; + VkImageView _iview = pCreateInfo->pAttachments[i]; + framebuffer->attachments[i] = anv_image_view_from_handle(_iview); } framebuffer->width = pCreateInfo->width; framebuffer->height = pCreateInfo->height; framebuffer->layers = pCreateInfo->layers; - anv_CreateDynamicViewportState(anv_device_to_handle(device), - &(VkDynamicViewportStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_DYNAMIC_VIEWPORT_STATE_CREATE_INFO, - .viewportAndScissorCount = 1, - .pViewports = (VkViewport[]) { - { - .originX = 0, - .originY = 0, - .width = pCreateInfo->width, - .height = pCreateInfo->height, - .minDepth = 0, - .maxDepth = 1 - }, - }, - .pScissors = (VkRect2D[]) { - { { 0, 0 }, - { pCreateInfo->width, pCreateInfo->height } }, - } - }, - &framebuffer->vp_state); - *pFramebuffer = anv_framebuffer_to_handle(framebuffer); return VK_SUCCESS; } -VkResult anv_DestroyFramebuffer( +void anv_DestroyFramebuffer( VkDevice _device, VkFramebuffer _fb) { ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_framebuffer, fb, _fb); - anv_DestroyDynamicViewportState(anv_device_to_handle(device), - fb->vp_state); anv_device_free(device, fb); - - return VK_SUCCESS; } VkResult anv_CreateRenderPass( @@ -2104,7 +1905,7 @@ VkResult anv_CreateRenderPass( for (uint32_t j = 0; j < desc->inputCount; j++) { subpass->input_attachments[j] - = desc->inputAttachments[j].attachment; + = desc->pInputAttachments[j].attachment; } } @@ -2115,18 +1916,18 @@ VkResult anv_CreateRenderPass( for (uint32_t j = 0; j < desc->colorCount; j++) { subpass->color_attachments[j] - = desc->colorAttachments[j].attachment; + = desc->pColorAttachments[j].attachment; } } - if (desc->resolveAttachments) { + if (desc->pResolveAttachments) { subpass->resolve_attachments = anv_device_alloc(device, desc->colorCount * sizeof(uint32_t), 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT); for (uint32_t j = 0; j < desc->colorCount; j++) { subpass->resolve_attachments[j] - = desc->resolveAttachments[j].attachment; + = desc->pResolveAttachments[j].attachment; } } @@ -2138,7 +1939,7 @@ VkResult anv_CreateRenderPass( return VK_SUCCESS; } -VkResult anv_DestroyRenderPass( +void anv_DestroyRenderPass( VkDevice _device, VkRenderPass _pass) { @@ -2157,8 +1958,6 @@ VkResult anv_DestroyRenderPass( } anv_device_free(device, pass); - - return VK_SUCCESS; } VkResult anv_GetRenderAreaGranularity( diff --git a/src/vulkan/anv_formats.c b/src/vulkan/anv_formats.c index 6173ee7872a..2690ff24692 100644 --- a/src/vulkan/anv_formats.c +++ b/src/vulkan/anv_formats.c @@ -120,7 +120,7 @@ static const struct anv_format anv_formats[] = { fmt(VK_FORMAT_R9G9B9E5_UFLOAT, R9G9B9E5_SHAREDEXP, .cpp = 4, .num_channels = 3), fmt(VK_FORMAT_D16_UNORM, R16_UNORM, .cpp = 2, .num_channels = 1, .depth_format = D16_UNORM), - fmt(VK_FORMAT_D24_UNORM, R24_UNORM_X8_TYPELESS, .cpp = 4, .num_channels = 1, .depth_format = D24_UNORM_X8_UINT), + fmt(VK_FORMAT_D24_UNORM_X8, R24_UNORM_X8_TYPELESS, .cpp = 4, .num_channels = 1, .depth_format = D24_UNORM_X8_UINT), fmt(VK_FORMAT_D32_SFLOAT, R32_FLOAT, .cpp = 4, .num_channels = 1, .depth_format = D32_FLOAT), fmt(VK_FORMAT_S8_UINT, R8_UINT, .cpp = 1, .num_channels = 1, .has_stencil = true), fmt(VK_FORMAT_D16_UNORM_S8_UINT, R16_UNORM, .cpp = 2, .num_channels = 2, .depth_format = D16_UNORM, .has_stencil = true), @@ -252,9 +252,9 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d { const struct surface_format_info *info; int gen; + VkFormatFeatureFlags flags; - if (format == NULL) - return VK_ERROR_INVALID_VALUE; + assert(format != NULL); gen = physical_device->info->gen * 10; if (physical_device->info->is_haswell) @@ -267,6 +267,10 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d if (anv_format_is_depth_or_stencil(format)) { tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; tiled |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; + tiled |= VK_FORMAT_FEATURE_BLIT_SOURCE_BIT; + if (format->depth_format) { + tiled |= VK_FORMAT_FEATURE_BLIT_DESTINATION_BIT; + } } else { /* The surface_formats table only contains color formats */ info = &surface_formats[format->surface_format]; @@ -274,12 +278,16 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d goto unsupported; if (info->sampling <= gen) { - linear |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; - tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; + flags = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | + VK_FORMAT_FEATURE_BLIT_SOURCE_BIT; + linear |= flags; + tiled |= flags; } if (info->render_target <= gen) { - linear |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; - tiled |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; + flags = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | + VK_FORMAT_FEATURE_BLIT_DESTINATION_BIT; + linear |= flags; + tiled |= flags; } if (info->alpha_blend <= gen) { linear |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; @@ -292,6 +300,7 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d out_properties->linearTilingFeatures = linear; out_properties->optimalTilingFeatures = tiled; + out_properties->bufferFeatures = 0; /* FINISHME */ return VK_SUCCESS; @@ -327,12 +336,16 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, + VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties) { ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice); const struct anv_format *format = anv_format_for_vk_format(_format); VkFormatProperties format_props; VkFormatFeatureFlags format_feature_flags; + VkExtent3D maxExtent; + uint32_t maxMipLevels; + uint32_t maxArraySize; VkResult result; result = anv_physical_device_get_format_properties(physical_device, format, @@ -351,6 +364,35 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( unreachable("bad VkImageTiling"); } + switch (type) { + default: + unreachable("bad VkImageType"); + case VK_IMAGE_TYPE_1D: + maxExtent.width = 16384; + maxExtent.height = 1; + maxExtent.depth = 1; + maxMipLevels = 15; /* log2(maxWidth) + 1 */ + maxArraySize = 2048; + break; + case VK_IMAGE_TYPE_2D: + /* FINISHME: Does this really differ for cube maps? The documentation + * for RENDER_SURFACE_STATE suggests so. + */ + maxExtent.width = 16384; + maxExtent.height = 16384; + maxExtent.depth = 1; + maxMipLevels = 15; /* log2(maxWidth) + 1 */ + maxArraySize = 2048; + break; + case VK_IMAGE_TYPE_3D: + maxExtent.width = 2048; + maxExtent.height = 2048; + maxExtent.depth = 2048; + maxMipLevels = 12; /* log2(maxWidth) + 1 */ + maxArraySize = 1; + break; + } + if (usage & VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT) { /* Meta implements transfers by sampling from the source image. */ if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) { @@ -387,7 +429,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( } } - if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_BIT) { + if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { if (!(format_feature_flags & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) { goto unsupported; } @@ -404,8 +446,12 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( } *pImageFormatProperties = (VkImageFormatProperties) { + .maxExtent = maxExtent, + .maxMipLevels = maxMipLevels, + .maxArraySize = maxArraySize, + /* FINISHME: Support multisampling */ - .maxSamples = 1, + .sampleCounts = VK_SAMPLE_COUNT_1_BIT, /* FINISHME: Accurately calculate * VkImageFormatProperties::maxResourceSize. @@ -417,7 +463,10 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( unsupported: *pImageFormatProperties = (VkImageFormatProperties) { - .maxSamples = 0, + .maxExtent = { 0, 0, 0 }, + .maxMipLevels = 0, + .maxArraySize = 0, + .sampleCounts = 0, .maxResourceSize = 0, }; diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index dce4208ed5f..e72c592905f 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -45,7 +45,6 @@ static const uint8_t anv_surf_type_from_image_type[] = { [VK_IMAGE_TYPE_1D] = SURFTYPE_1D, [VK_IMAGE_TYPE_2D] = SURFTYPE_2D, [VK_IMAGE_TYPE_3D] = SURFTYPE_3D, - }; static const struct anv_image_view_info @@ -61,10 +60,10 @@ anv_image_view_info_table[] = { #undef INFO }; -const struct anv_image_view_info * +struct anv_image_view_info anv_image_view_info_for_vk_image_view_type(VkImageViewType type) { - return &anv_image_view_info_table[type]; + return anv_image_view_info_table[type]; } static const struct anv_surf_type_limits { @@ -103,10 +102,7 @@ static const struct anv_tile_info { [WMAJOR] = { 128, 32, 4096 }, }; -/** - * Return -1 on failure. - */ -static int8_t +static uint8_t anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info) { if (anv_info->force_tile_mode) @@ -118,11 +114,8 @@ anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info) switch (anv_info->vk_info->tiling) { case VK_IMAGE_TILING_LINEAR: - if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) { - return -1; - } else { - return LINEAR; - } + assert(anv_info->vk_info->format != VK_FORMAT_S8_UINT); + return LINEAR; case VK_IMAGE_TILING_OPTIMAL: if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) { return WMAJOR; @@ -154,10 +147,7 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, const VkExtent3D *restrict extent = &create_info->vk_info->extent; const uint32_t levels = create_info->vk_info->mipLevels; const uint32_t array_size = create_info->vk_info->arraySize; - - const int8_t tile_mode = anv_image_choose_tile_mode(create_info); - if (tile_mode == -1) - return vk_error(VK_ERROR_INVALID_IMAGE); + const uint8_t tile_mode = anv_image_choose_tile_mode(create_info); const struct anv_tile_info *tile_info = &anv_tile_info_table[tile_mode]; @@ -259,6 +249,26 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, return VK_SUCCESS; } +static VkImageUsageFlags +anv_image_get_full_usage(const VkImageCreateInfo *info) +{ + VkImageUsageFlags usage = info->usage; + + if (usage & VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT) { + /* Meta will transfer from the image by binding it as a texture. */ + usage |= VK_IMAGE_USAGE_SAMPLED_BIT; + } + + if (usage & VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT) { + /* Meta will transfer to the image by binding it as a color attachment, + * even if the image format is not a color format. + */ + usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + } + + return usage; +} + VkResult anv_image_create(VkDevice _device, const struct anv_image_create_info *create_info, @@ -286,12 +296,10 @@ anv_image_create(VkDevice _device, const struct anv_surf_type_limits *limits = &anv_surf_type_limits[surf_type]; - if (extent->width > limits->width || - extent->height > limits->height || - extent->depth > limits->depth) { - /* TODO(chadv): What is the correct error? */ - return vk_errorf(VK_ERROR_INVALID_MEMORY_SIZE, "image extent is too large"); - } + /* Errors should be caught by VkImageFormatProperties. */ + assert(extent->width <= limits->width); + assert(extent->height <= limits->height); + assert(extent->depth <= limits->depth); image = anv_device_alloc(device, sizeof(*image), 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT); @@ -304,7 +312,17 @@ anv_image_create(VkDevice _device, image->format = anv_format_for_vk_format(pCreateInfo->format); image->levels = pCreateInfo->mipLevels; image->array_size = pCreateInfo->arraySize; - image->surf_type = surf_type; + image->usage = anv_image_get_full_usage(pCreateInfo); + image->surface_type = surf_type; + + if (image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_STORAGE_BIT)) { + image->needs_nonrt_surface_state = true; + } + + if (image->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) { + image->needs_color_rt_surface_state = true; + } if (likely(anv_format_is_color(image->format))) { r = anv_image_make_surface(create_info, image->format, @@ -353,14 +371,12 @@ anv_CreateImage(VkDevice device, pImage); } -VkResult +void anv_DestroyImage(VkDevice _device, VkImage _image) { ANV_FROM_HANDLE(anv_device, device, _device); anv_device_free(device, anv_image_from_handle(_image)); - - return VK_SUCCESS; } VkResult anv_GetImageSubresourceLayout( @@ -372,13 +388,6 @@ VkResult anv_GetImageSubresourceLayout( stub_return(VK_UNSUPPORTED); } -void -anv_surface_view_fini(struct anv_device *device, - struct anv_surface_view *view) -{ - anv_state_pool_free(&device->surface_state_pool, view->surface_state); -} - VkResult anv_validate_CreateImageView(VkDevice _device, const VkImageViewCreateInfo *pCreateInfo, @@ -415,43 +424,47 @@ anv_validate_CreateImageView(VkDevice _device, assert(pCreateInfo->channels.a <= VK_CHANNEL_SWIZZLE_END_RANGE); /* Validate subresource. */ - assert(subresource->aspect >= VK_IMAGE_ASPECT_BEGIN_RANGE); - assert(subresource->aspect <= VK_IMAGE_ASPECT_END_RANGE); + assert(subresource->aspectMask != 0); assert(subresource->mipLevels > 0); assert(subresource->arraySize > 0); assert(subresource->baseMipLevel < image->levels); assert(subresource->baseMipLevel + subresource->mipLevels <= image->levels); - assert(subresource->baseArraySlice < image->array_size); - assert(subresource->baseArraySlice + subresource->arraySize <= image->array_size); + assert(subresource->baseArrayLayer < image->array_size); + assert(subresource->baseArrayLayer + subresource->arraySize <= image->array_size); assert(pView); if (view_info->is_cube) { - assert(subresource->baseArraySlice % 6 == 0); + assert(subresource->baseArrayLayer % 6 == 0); assert(subresource->arraySize % 6 == 0); } + const VkImageAspectFlags ds_flags = VK_IMAGE_ASPECT_DEPTH_BIT + | VK_IMAGE_ASPECT_STENCIL_BIT; + /* Validate format. */ - switch (subresource->aspect) { - case VK_IMAGE_ASPECT_COLOR: + if (subresource->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { + assert(subresource->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT); assert(!image->format->depth_format); assert(!image->format->has_stencil); assert(!view_format_info->depth_format); assert(!view_format_info->has_stencil); assert(view_format_info->cpp == image->format->cpp); - break; - case VK_IMAGE_ASPECT_DEPTH: - assert(image->format->depth_format); - assert(view_format_info->depth_format); - assert(view_format_info->cpp == image->format->cpp); - break; - case VK_IMAGE_ASPECT_STENCIL: - /* FINISHME: Is it legal to have an R8 view of S8? */ - assert(image->format->has_stencil); - assert(view_format_info->has_stencil); - break; - default: - assert(!"bad VkImageAspect"); - break; + } else if (subresource->aspectMask & ds_flags) { + assert((subresource->aspectMask & ~ds_flags) == 0); + + if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) { + assert(image->format->depth_format); + assert(view_format_info->depth_format); + assert(view_format_info->cpp == image->format->cpp); + } + + if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL) { + /* FINISHME: Is it legal to have an R8 view of S8? */ + assert(image->format->has_stencil); + assert(view_format_info->has_stencil); + } + } else { + assert(!"bad VkImageSubresourceRange::aspectFlags"); } return anv_CreateImageView(_device, pCreateInfo, pView); @@ -463,6 +476,29 @@ anv_image_view_init(struct anv_image_view *iview, const VkImageViewCreateInfo* pCreateInfo, struct anv_cmd_buffer *cmd_buffer) { + ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); + const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange; + + assert(range->arraySize > 0); + assert(range->baseMipLevel < image->levels); + assert(image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_STORAGE_BIT | + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)); + + switch (image->type) { + default: + unreachable("bad VkImageType"); + case VK_IMAGE_TYPE_1D: + case VK_IMAGE_TYPE_2D: + assert(range->baseArrayLayer + range->arraySize - 1 <= image->array_size); + break; + case VK_IMAGE_TYPE_3D: + assert(range->baseArrayLayer + range->arraySize - 1 + <= anv_minify(image->extent.depth, range->baseMipLevel)); + break; + } + switch (device->info.gen) { case 7: gen7_image_view_init(iview, device, pCreateInfo, cmd_buffer); @@ -495,143 +531,109 @@ anv_CreateImageView(VkDevice _device, return VK_SUCCESS; } -VkResult -anv_DestroyImageView(VkDevice _device, VkImageView _iview) +static void +anv_image_view_destroy(struct anv_device *device, + struct anv_image_view *iview) { - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_image_view, iview, _iview); + if (iview->image->needs_color_rt_surface_state) { + anv_state_pool_free(&device->surface_state_pool, + iview->color_rt_surface_state); + } - anv_surface_view_fini(device, &iview->view); - anv_device_free(device, iview); + if (iview->image->needs_nonrt_surface_state) { + anv_state_pool_free(&device->surface_state_pool, + iview->nonrt_surface_state); + } - return VK_SUCCESS; + anv_device_free(device, iview); } -static void -anv_depth_stencil_view_init(struct anv_depth_stencil_view *view, - const VkAttachmentViewCreateInfo *pCreateInfo) +void +anv_DestroyImageView(VkDevice _device, VkImageView _iview) { - ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); - - view->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL; - - /* XXX: We don't handle any of these */ - anv_assert(pCreateInfo->mipLevel == 0); - anv_assert(pCreateInfo->baseArraySlice == 0); - anv_assert(pCreateInfo->arraySize == 1); - - view->image = image; - view->format = anv_format_for_vk_format(pCreateInfo->format); + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_image_view, iview, _iview); - assert(anv_format_is_depth_or_stencil(image->format)); - assert(anv_format_is_depth_or_stencil(view->format)); + anv_image_view_destroy(device, iview); } struct anv_surface * -anv_image_get_surface_for_aspect(struct anv_image *image, VkImageAspect aspect) +anv_image_get_surface_for_aspect_mask(struct anv_image *image, VkImageAspectFlags aspect_mask) { - switch (aspect) { - case VK_IMAGE_ASPECT_COLOR: - assert(anv_format_is_color(image->format)); - return &image->color_surface; - case VK_IMAGE_ASPECT_DEPTH: + switch (aspect_mask) { + case VK_IMAGE_ASPECT_COLOR_BIT: + /* Dragons will eat you. + * + * Meta attaches all destination surfaces as color render targets. Guess + * what surface the Meta Dragons really want. + */ + if (image->format->depth_format && image->format->has_stencil) { + anv_finishme("combined depth stencil formats"); + return &image->depth_surface; + } else if (image->format->depth_format) { + return &image->depth_surface; + } else if (image->format->has_stencil) { + return &image->stencil_surface; + } else { + return &image->color_surface; + } + break; + case VK_IMAGE_ASPECT_DEPTH_BIT: assert(image->format->depth_format); return &image->depth_surface; - case VK_IMAGE_ASPECT_STENCIL: + case VK_IMAGE_ASPECT_STENCIL_BIT: assert(image->format->has_stencil); - anv_finishme("stencil image views"); return &image->stencil_surface; + case VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT: + if (image->format->depth_format && image->format->has_stencil) { + /* FINISHME: The Vulkan spec (git a511ba2) requires support for combined + * depth stencil formats. Specifically, it states: + * + * At least one of ename:VK_FORMAT_D24_UNORM_S8_UINT or + * ename:VK_FORMAT_D32_SFLOAT_S8_UINT must be supported. + */ + anv_finishme("combined depthstencil aspect"); + return &image->depth_surface; + } else if (image->format->depth_format) { + return &image->depth_surface; + } else if (image->format->has_stencil) { + return &image->stencil_surface; + } + /* fallthrough */ default: unreachable("image does not have aspect"); return NULL; } } -/** The attachment may be a color view into a non-color image. */ -struct anv_surface * -anv_image_get_surface_for_color_attachment(struct anv_image *image) -{ - if (anv_format_is_color(image->format)) { - return &image->color_surface; - } else if (image->format->depth_format) { - return &image->depth_surface; - } else if (image->format->has_stencil) { - return &image->stencil_surface; - } else { - unreachable("image has bad format"); - return NULL; - } -} - -void -anv_color_attachment_view_init(struct anv_color_attachment_view *aview, - struct anv_device *device, - const VkAttachmentViewCreateInfo* pCreateInfo, - struct anv_cmd_buffer *cmd_buffer) -{ - switch (device->info.gen) { - case 7: - gen7_color_attachment_view_init(aview, device, pCreateInfo, cmd_buffer); - break; - case 8: - gen8_color_attachment_view_init(aview, device, pCreateInfo, cmd_buffer); - break; - default: - unreachable("unsupported gen\n"); - } -} - -VkResult -anv_CreateAttachmentView(VkDevice _device, - const VkAttachmentViewCreateInfo *pCreateInfo, - VkAttachmentView *pView) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO); - - const struct anv_format *format = - anv_format_for_vk_format(pCreateInfo->format); - - if (anv_format_is_depth_or_stencil(format)) { - struct anv_depth_stencil_view *view = - anv_device_alloc(device, sizeof(*view), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (view == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - anv_depth_stencil_view_init(view, pCreateInfo); - - *pView = anv_attachment_view_to_handle(&view->base); - } else { - struct anv_color_attachment_view *view = - anv_device_alloc(device, sizeof(*view), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (view == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - anv_color_attachment_view_init(view, device, pCreateInfo, NULL); - - *pView = anv_attachment_view_to_handle(&view->base); - } - - return VK_SUCCESS; -} - -VkResult -anv_DestroyAttachmentView(VkDevice _device, VkAttachmentView _view) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_attachment_view, view, _view); - - if (view->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR) { - struct anv_color_attachment_view *aview = - (struct anv_color_attachment_view *)view; - - anv_surface_view_fini(device, &aview->view); - } - - anv_device_free(device, view); - - return VK_SUCCESS; -} +#if 0 + VkImageAspectFlags aspect_mask = 0; + if (format->depth_format) + aspect_mask |= VK_IMAGE_ASPECT_DEPTH_BIT; + if (format->has_stencil) + aspect_mask |= VK_IMAGE_ASPECT_STENCIL_BIT; + if (!aspect_mask) + aspect_mask |= VK_IMAGE_ASPECT_COLOR_BIT; + + anv_image_view_init(iview, device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .image = info->image, + .viewType = VK_IMAGE_VIEW_TYPE_2D, + .format = info->format, + .channels = { + .r = VK_CHANNEL_SWIZZLE_R, + .g = VK_CHANNEL_SWIZZLE_G, + .b = VK_CHANNEL_SWIZZLE_B, + .a = VK_CHANNEL_SWIZZLE_A, + }, + .subresourceRange = { + .aspectMask = aspect_mask, + .baseMipLevel = info->mipLevel, + .mipLevels = 1, + .baseArrayLayer = info->baseArraySlice, + .arraySize = info->arraySize, + }, + }, + NULL); +#endif diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index 91b5024f1a4..565575ab219 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -67,7 +67,7 @@ build_nir_vertex_shader(bool attr_flat) } static nir_shader * -build_nir_clear_fragment_shader() +build_nir_clear_fragment_shader(void) { nir_builder b; @@ -253,7 +253,7 @@ anv_device_init_meta_clear_state(struct anv_device *device) .depthTestEnable = true, .depthWriteEnable = true, .depthCompareOp = VK_COMPARE_OP_ALWAYS, - .depthBoundsEnable = false, + .depthBoundsTestEnable = false, .stencilTestEnable = true, .front = (VkStencilOpState) { .stencilPassOp = VK_STENCIL_OP_REPLACE, @@ -293,20 +293,22 @@ struct anv_saved_state { struct anv_vertex_binding old_vertex_bindings[NUM_VB_USED]; struct anv_descriptor_set *old_descriptor_set0; struct anv_pipeline *old_pipeline; - struct anv_dynamic_ds_state *old_ds_state; - struct anv_dynamic_cb_state *old_cb_state; + uint32_t dynamic_flags; + struct anv_dynamic_state dynamic; }; static void anv_cmd_buffer_save(struct anv_cmd_buffer *cmd_buffer, - struct anv_saved_state *state) + struct anv_saved_state *state, + uint32_t dynamic_state) { state->old_pipeline = cmd_buffer->state.pipeline; state->old_descriptor_set0 = cmd_buffer->state.descriptors[0].set; memcpy(state->old_vertex_bindings, cmd_buffer->state.vertex_bindings, sizeof(state->old_vertex_bindings)); - state->old_ds_state = cmd_buffer->state.ds_state; - state->old_cb_state = cmd_buffer->state.cb_state; + state->dynamic_flags = dynamic_state; + anv_dynamic_state_copy(&state->dynamic, &cmd_buffer->state.dynamic, + dynamic_state); } static void @@ -322,15 +324,9 @@ anv_cmd_buffer_restore(struct anv_cmd_buffer *cmd_buffer, cmd_buffer->state.dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY; cmd_buffer->state.descriptors_dirty |= VK_SHADER_STAGE_VERTEX_BIT; - if (cmd_buffer->state.ds_state != state->old_ds_state) { - cmd_buffer->state.ds_state = state->old_ds_state; - cmd_buffer->state.dirty |= ANV_CMD_BUFFER_DS_DIRTY; - } - - if (cmd_buffer->state.cb_state != state->old_cb_state) { - cmd_buffer->state.cb_state = state->old_cb_state; - cmd_buffer->state.dirty |= ANV_CMD_BUFFER_CB_DIRTY; - } + anv_dynamic_state_copy(&cmd_buffer->state.dynamic, &state->dynamic, + state->dynamic_flags); + cmd_buffer->state.dirty |= state->dynamic_flags; } struct vue_header { @@ -396,25 +392,8 @@ meta_emit_clear(struct anv_cmd_buffer *cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, device->meta_state.clear.pipeline); - /* We don't need anything here, only set if not already set. */ - if (cmd_buffer->state.rs_state == NULL) - anv_CmdBindDynamicRasterState(anv_cmd_buffer_to_handle(cmd_buffer), - device->meta_state.shared.rs_state); - - if (cmd_buffer->state.vp_state == NULL) - anv_CmdBindDynamicViewportState(anv_cmd_buffer_to_handle(cmd_buffer), - cmd_buffer->state.framebuffer->vp_state); - - if (cmd_buffer->state.ds_state == NULL) - anv_CmdBindDynamicDepthStencilState(anv_cmd_buffer_to_handle(cmd_buffer), - device->meta_state.shared.ds_state); - - if (cmd_buffer->state.cb_state == NULL) - anv_CmdBindDynamicColorBlendState(anv_cmd_buffer_to_handle(cmd_buffer), - device->meta_state.shared.cb_state); - ANV_CALL(CmdDraw)(anv_cmd_buffer_to_handle(cmd_buffer), - 0, 3, 0, num_instances); + 3, num_instances, 0, 0); } void @@ -427,6 +406,9 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer, if (pass->has_stencil_clear_attachment) anv_finishme("stencil clear"); + /* FINISHME: Rethink how we count clear attachments in light of + * 0.138.2 -> 0.170.2 diff. + */ if (pass->num_color_clear_attachments == 0 && !pass->has_depth_clear_attachment) return; @@ -455,7 +437,7 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer, } else if (att->format->depth_format) { assert(ds_attachment == VK_ATTACHMENT_UNUSED); ds_attachment = i; - ds_clear_value= clear_values[ds_attachment].ds; + ds_clear_value = clear_values[ds_attachment].depthStencil; } } else if (att->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) { assert(att->format->has_stencil); @@ -463,7 +445,9 @@ anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer, } } - anv_cmd_buffer_save(cmd_buffer, &saved_state); + anv_cmd_buffer_save(cmd_buffer, &saved_state, + (1 << VK_DYNAMIC_STATE_VIEWPORT)); + cmd_buffer->state.dynamic.viewport.count = 0; struct anv_subpass subpass = { .input_count = 0, @@ -499,13 +483,13 @@ meta_blit_get_src_image_view_type(const struct anv_image *src_image) static uint32_t meta_blit_get_dest_view_base_array_slice(const struct anv_image *dest_image, - const VkImageSubresource *dest_subresource, + const VkImageSubresourceCopy *dest_subresource, const VkOffset3D *dest_offset) { switch (dest_image->type) { case VK_IMAGE_TYPE_1D: case VK_IMAGE_TYPE_2D: - return dest_subresource->arraySlice; + return dest_subresource->arrayLayer; case VK_IMAGE_TYPE_3D: /* HACK: Vulkan does not allow attaching a 3D image to a framebuffer, * but meta does it anyway. When doing so, we translate the @@ -700,20 +684,8 @@ static void meta_prepare_blit(struct anv_cmd_buffer *cmd_buffer, struct anv_saved_state *saved_state) { - struct anv_device *device = cmd_buffer->device; - - anv_cmd_buffer_save(cmd_buffer, saved_state); - - /* We don't need anything here, only set if not already set. */ - if (cmd_buffer->state.rs_state == NULL) - anv_CmdBindDynamicRasterState(anv_cmd_buffer_to_handle(cmd_buffer), - device->meta_state.shared.rs_state); - if (cmd_buffer->state.ds_state == NULL) - anv_CmdBindDynamicDepthStencilState(anv_cmd_buffer_to_handle(cmd_buffer), - device->meta_state.shared.ds_state); - - anv_CmdBindDynamicColorBlendState(anv_cmd_buffer_to_handle(cmd_buffer), - device->meta_state.shared.cb_state); + anv_cmd_buffer_save(cmd_buffer, saved_state, + (1 << VK_DYNAMIC_STATE_VIEWPORT)); } struct blit_region { @@ -726,11 +698,11 @@ struct blit_region { static void meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, struct anv_image *src_image, - struct anv_image_view *src_view, + struct anv_image_view *src_iview, VkOffset3D src_offset, VkExtent3D src_extent, struct anv_image *dest_image, - struct anv_color_attachment_view *dest_view, + struct anv_image_view *dest_iview, VkOffset3D dest_offset, VkExtent3D dest_extent) { @@ -755,9 +727,9 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, dest_offset.y + dest_extent.height, }, .tex_coord = { - (float)(src_offset.x + src_extent.width) / (float)src_view->extent.width, - (float)(src_offset.y + src_extent.height) / (float)src_view->extent.height, - (float)(src_offset.z + src_extent.depth) / (float)src_view->extent.depth, + (float)(src_offset.x + src_extent.width) / (float)src_iview->extent.width, + (float)(src_offset.y + src_extent.height) / (float)src_iview->extent.height, + (float)(src_offset.z + src_extent.depth) / (float)src_iview->extent.depth, }, }; @@ -767,9 +739,9 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, dest_offset.y + dest_extent.height, }, .tex_coord = { - (float)src_offset.x / (float)src_view->extent.width, - (float)(src_offset.y + src_extent.height) / (float)src_view->extent.height, - (float)(src_offset.z + src_extent.depth) / (float)src_view->extent.depth, + (float)src_offset.x / (float)src_iview->extent.width, + (float)(src_offset.y + src_extent.height) / (float)src_iview->extent.height, + (float)(src_offset.z + src_extent.depth) / (float)src_iview->extent.depth, }, }; @@ -779,9 +751,9 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, dest_offset.y, }, .tex_coord = { - (float)src_offset.x / (float)src_view->extent.width, - (float)src_offset.y / (float)src_view->extent.height, - (float)src_offset.z / (float)src_view->extent.depth, + (float)src_offset.x / (float)src_iview->extent.width, + (float)src_offset.y / (float)src_iview->extent.height, + (float)src_offset.z / (float)src_iview->extent.depth, }, }; @@ -802,11 +774,10 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, sizeof(struct vue_header), }); - uint32_t count; VkDescriptorSet set; anv_AllocDescriptorSets(anv_device_to_handle(device), dummy_desc_pool, VK_DESCRIPTOR_SET_USAGE_ONE_SHOT, - 1, &device->meta_state.blit.ds_layout, &set, &count); + 1, &device->meta_state.blit.ds_layout, &set); anv_UpdateDescriptorSets(anv_device_to_handle(device), 1, /* writeCount */ (VkWriteDescriptorSet[]) { @@ -819,7 +790,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, .pDescriptors = (VkDescriptorInfo[]) { { - .imageView = anv_image_view_to_handle(src_view), + .imageView = anv_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL }, } @@ -831,14 +802,11 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, &(VkFramebufferCreateInfo) { .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .attachmentCount = 1, - .pAttachments = (VkAttachmentBindInfo[]) { - { - .view = anv_attachment_view_to_handle(&dest_view->base), - .layout = VK_IMAGE_LAYOUT_GENERAL - } + .pAttachments = (VkImageView[]) { + anv_image_view_to_handle(dest_iview), }, - .width = dest_view->base.extent.width, - .height = dest_view->base.extent.height, + .width = dest_iview->extent.width, + .height = dest_iview->extent.height, .layers = 1 }, &fb); @@ -849,7 +817,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, .attachmentCount = 1, .pAttachments = &(VkAttachmentDescription) { .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION, - .format = dest_view->view.format->vk_format, + .format = dest_iview->format->vk_format, .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, .storeOp = VK_ATTACHMENT_STORE_OP_STORE, .initialLayout = VK_IMAGE_LAYOUT_GENERAL, @@ -861,17 +829,17 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .inputCount = 0, .colorCount = 1, - .colorAttachments = &(VkAttachmentReference) { + .pColorAttachments = &(VkAttachmentReference) { .attachment = 0, .layout = VK_IMAGE_LAYOUT_GENERAL, }, - .resolveAttachments = NULL, + .pResolveAttachments = NULL, .depthStencilAttachment = (VkAttachmentReference) { .attachment = VK_ATTACHMENT_UNUSED, .layout = VK_IMAGE_LAYOUT_GENERAL, }, .preserveCount = 1, - .preserveAttachments = &(VkAttachmentReference) { + .pPreserveAttachments = &(VkAttachmentReference) { .attachment = 0, .layout = VK_IMAGE_LAYOUT_GENERAL, }, @@ -888,8 +856,8 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, .offset = { dest_offset.x, dest_offset.y }, .extent = { dest_extent.width, dest_extent.height }, }, - .attachmentCount = 1, - .pAttachmentClearValues = NULL, + .clearValueCount = 0, + .pClearValues = NULL, }, VK_RENDER_PASS_CONTENTS_INLINE); VkPipeline pipeline; @@ -914,15 +882,22 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); } - anv_CmdBindDynamicViewportState(anv_cmd_buffer_to_handle(cmd_buffer), - anv_framebuffer_from_handle(fb)->vp_state); + anv_CmdSetViewport(anv_cmd_buffer_to_handle(cmd_buffer), 1, + &(VkViewport) { + .originX = 0.0f, + .originY = 0.0f, + .width = dest_iview->extent.width, + .height = dest_iview->extent.height, + .minDepth = 0.0f, + .maxDepth = 1.0f, + }); anv_CmdBindDescriptorSets(anv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_GRAPHICS, device->meta_state.blit.pipeline_layout, 0, 1, &set, 0, NULL); - ANV_CALL(CmdDraw)(anv_cmd_buffer_to_handle(cmd_buffer), 0, 3, 0, 1); + ANV_CALL(CmdDraw)(anv_cmd_buffer_to_handle(cmd_buffer), 3, 1, 0, 0); ANV_CALL(CmdEndRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer)); @@ -979,12 +954,16 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer, .arraySize = 1, .samples = 1, .tiling = VK_IMAGE_TILING_LINEAR, - .usage = VK_IMAGE_USAGE_SAMPLED_BIT, + .usage = 0, .flags = 0, }; - VkImage src_image, dest_image; + VkImage src_image; + image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; anv_CreateImage(vk_device, &image_info, &src_image); + + VkImage dest_image; + image_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; anv_CreateImage(vk_device, &image_info, &dest_image); /* We could use a vk call to bind memory, but that would require @@ -995,8 +974,8 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer, anv_image_from_handle(dest_image)->bo = dest; anv_image_from_handle(dest_image)->offset = dest_offset; - struct anv_image_view src_view; - anv_image_view_init(&src_view, cmd_buffer->device, + struct anv_image_view src_iview; + anv_image_view_init(&src_iview, cmd_buffer->device, &(VkImageViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = src_image, @@ -1009,34 +988,45 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer, VK_CHANNEL_SWIZZLE_A }, .subresourceRange = { - .aspect = VK_IMAGE_ASPECT_COLOR, + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = 0, .mipLevels = 1, - .baseArraySlice = 0, + .baseArrayLayer = 0, .arraySize = 1 }, }, cmd_buffer); - struct anv_color_attachment_view dest_view; - anv_color_attachment_view_init(&dest_view, cmd_buffer->device, - &(VkAttachmentViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, + struct anv_image_view dest_iview; + anv_image_view_init(&dest_iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = dest_image, + .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = copy_format, - .mipLevel = 0, - .baseArraySlice = 0, - .arraySize = 1, + .channels = { + .r = VK_CHANNEL_SWIZZLE_R, + .g = VK_CHANNEL_SWIZZLE_G, + .b = VK_CHANNEL_SWIZZLE_B, + .a = VK_CHANNEL_SWIZZLE_A, + }, + .subresourceRange = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = 0, + .mipLevels = 1, + .baseArrayLayer = 0, + .arraySize = 1, + }, }, cmd_buffer); meta_emit_blit(cmd_buffer, anv_image_from_handle(src_image), - &src_view, + &src_iview, (VkOffset3D) { 0, 0, 0 }, (VkExtent3D) { width, height, 1 }, anv_image_from_handle(dest_image), - &dest_view, + &dest_iview, (VkOffset3D) { 0, 0, 0 }, (VkExtent3D) { width, height, 1 }); @@ -1135,7 +1125,7 @@ void anv_CmdCopyImage( ANV_FROM_HANDLE(anv_image, src_image, srcImage); ANV_FROM_HANDLE(anv_image, dest_image, destImage); - const VkImageViewType src_view_type = + const VkImageViewType src_iview_type = meta_blit_get_src_image_view_type(src_image); struct anv_saved_state saved_state; @@ -1143,12 +1133,12 @@ void anv_CmdCopyImage( meta_prepare_blit(cmd_buffer, &saved_state); for (unsigned r = 0; r < regionCount; r++) { - struct anv_image_view src_view; - anv_image_view_init(&src_view, cmd_buffer->device, + struct anv_image_view src_iview; + anv_image_view_init(&src_iview, cmd_buffer->device, &(VkImageViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = srcImage, - .viewType = src_view_type, + .viewType = src_iview_type, .format = src_image->format->vk_format, .channels = { VK_CHANNEL_SWIZZLE_R, @@ -1157,10 +1147,10 @@ void anv_CmdCopyImage( VK_CHANNEL_SWIZZLE_A }, .subresourceRange = { - .aspect = pRegions[r].srcSubresource.aspect, + .aspectMask = 1 << pRegions[r].srcSubresource.aspect, .baseMipLevel = pRegions[r].srcSubresource.mipLevel, .mipLevels = 1, - .baseArraySlice = pRegions[r].srcSubresource.arraySlice, + .baseArrayLayer = pRegions[r].srcSubresource.arrayLayer, .arraySize = 1 }, }, @@ -1177,26 +1167,40 @@ void anv_CmdCopyImage( &pRegions[r].destSubresource, &pRegions[r].destOffset); + if (pRegions[r].srcSubresource.arraySize > 1) + anv_finishme("FINISHME: copy multiple array layers"); + if (pRegions[r].extent.depth > 1) anv_finishme("FINISHME: copy multiple depth layers"); - struct anv_color_attachment_view dest_view; - anv_color_attachment_view_init(&dest_view, cmd_buffer->device, - &(VkAttachmentViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, + struct anv_image_view dest_iview; + anv_image_view_init(&dest_iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = destImage, + .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = dest_image->format->vk_format, - .mipLevel = pRegions[r].destSubresource.mipLevel, - .baseArraySlice = dest_array_slice, - .arraySize = 1, + .channels = { + VK_CHANNEL_SWIZZLE_R, + VK_CHANNEL_SWIZZLE_G, + VK_CHANNEL_SWIZZLE_B, + VK_CHANNEL_SWIZZLE_A + }, + .subresourceRange = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = pRegions[r].destSubresource.mipLevel, + .mipLevels = 1, + .baseArrayLayer = dest_array_slice, + .arraySize = 1 + }, }, cmd_buffer); meta_emit_blit(cmd_buffer, - src_image, &src_view, + src_image, &src_iview, pRegions[r].srcOffset, pRegions[r].extent, - dest_image, &dest_view, + dest_image, &dest_iview, dest_offset, pRegions[r].extent); } @@ -1219,7 +1223,7 @@ void anv_CmdBlitImage( ANV_FROM_HANDLE(anv_image, src_image, srcImage); ANV_FROM_HANDLE(anv_image, dest_image, destImage); - const VkImageViewType src_view_type = + const VkImageViewType src_iview_type = meta_blit_get_src_image_view_type(src_image); struct anv_saved_state saved_state; @@ -1229,12 +1233,12 @@ void anv_CmdBlitImage( meta_prepare_blit(cmd_buffer, &saved_state); for (unsigned r = 0; r < regionCount; r++) { - struct anv_image_view src_view; - anv_image_view_init(&src_view, cmd_buffer->device, + struct anv_image_view src_iview; + anv_image_view_init(&src_iview, cmd_buffer->device, &(VkImageViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = srcImage, - .viewType = src_view_type, + .viewType = src_iview_type, .format = src_image->format->vk_format, .channels = { VK_CHANNEL_SWIZZLE_R, @@ -1243,10 +1247,10 @@ void anv_CmdBlitImage( VK_CHANNEL_SWIZZLE_A }, .subresourceRange = { - .aspect = pRegions[r].srcSubresource.aspect, + .aspectMask = 1 << pRegions[r].srcSubresource.aspect, .baseMipLevel = pRegions[r].srcSubresource.mipLevel, .mipLevels = 1, - .baseArraySlice = pRegions[r].srcSubresource.arraySlice, + .baseArrayLayer = pRegions[r].srcSubresource.arrayLayer, .arraySize = 1 }, }, @@ -1263,26 +1267,40 @@ void anv_CmdBlitImage( &pRegions[r].destSubresource, &pRegions[r].destOffset); + if (pRegions[r].srcSubresource.arraySize > 1) + anv_finishme("FINISHME: copy multiple array layers"); + if (pRegions[r].destExtent.depth > 1) anv_finishme("FINISHME: copy multiple depth layers"); - struct anv_color_attachment_view dest_view; - anv_color_attachment_view_init(&dest_view, cmd_buffer->device, - &(VkAttachmentViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, + struct anv_image_view dest_iview; + anv_image_view_init(&dest_iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = destImage, + .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = dest_image->format->vk_format, - .mipLevel = pRegions[r].destSubresource.mipLevel, - .baseArraySlice = dest_array_slice, - .arraySize = 1, + .channels = { + VK_CHANNEL_SWIZZLE_R, + VK_CHANNEL_SWIZZLE_G, + VK_CHANNEL_SWIZZLE_B, + VK_CHANNEL_SWIZZLE_A + }, + .subresourceRange = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = pRegions[r].destSubresource.mipLevel, + .mipLevels = 1, + .baseArrayLayer = dest_array_slice, + .arraySize = 1 + }, }, cmd_buffer); meta_emit_blit(cmd_buffer, - src_image, &src_view, + src_image, &src_iview, pRegions[r].srcOffset, pRegions[r].srcExtent, - dest_image, &dest_view, + dest_image, &dest_iview, dest_offset, pRegions[r].destExtent); } @@ -1292,6 +1310,7 @@ void anv_CmdBlitImage( static VkImage make_image_for_buffer(VkDevice vk_device, VkBuffer vk_buffer, VkFormat format, + VkImageUsageFlags usage, const VkBufferImageCopy *copy) { ANV_FROM_HANDLE(anv_buffer, buffer, vk_buffer); @@ -1314,7 +1333,7 @@ make_image_for_buffer(VkDevice vk_device, VkBuffer vk_buffer, VkFormat format, .arraySize = 1, .samples = 1, .tiling = VK_IMAGE_TILING_LINEAR, - .usage = VK_IMAGE_USAGE_SAMPLED_BIT, + .usage = usage, .flags = 0, }, &vk_image); assert(result == VK_SUCCESS); @@ -1356,11 +1375,10 @@ void anv_CmdCopyBufferToImage( } VkImage srcImage = make_image_for_buffer(vk_device, srcBuffer, - proxy_format, - &pRegions[r]); + proxy_format, VK_IMAGE_USAGE_SAMPLED_BIT, &pRegions[r]); - struct anv_image_view src_view; - anv_image_view_init(&src_view, cmd_buffer->device, + struct anv_image_view src_iview; + anv_image_view_init(&src_iview, cmd_buffer->device, &(VkImageViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = srcImage, @@ -1373,10 +1391,10 @@ void anv_CmdCopyBufferToImage( VK_CHANNEL_SWIZZLE_A }, .subresourceRange = { - .aspect = proxy_aspect, + .aspectMask = 1 << proxy_aspect, .baseMipLevel = 0, .mipLevels = 1, - .baseArraySlice = 0, + .baseArrayLayer = 0, .arraySize = 1 }, }, @@ -1396,25 +1414,36 @@ void anv_CmdCopyBufferToImage( if (pRegions[r].imageExtent.depth > 1) anv_finishme("FINISHME: copy multiple depth layers"); - struct anv_color_attachment_view dest_view; - anv_color_attachment_view_init(&dest_view, cmd_buffer->device, - &(VkAttachmentViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, + struct anv_image_view dest_iview; + anv_image_view_init(&dest_iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = anv_image_to_handle(dest_image), + .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = proxy_format, - .mipLevel = pRegions[r].imageSubresource.mipLevel, - .baseArraySlice = dest_array_slice, - .arraySize = 1, + .channels = { + VK_CHANNEL_SWIZZLE_R, + VK_CHANNEL_SWIZZLE_G, + VK_CHANNEL_SWIZZLE_B, + VK_CHANNEL_SWIZZLE_A + }, + .subresourceRange = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = pRegions[r].imageSubresource.mipLevel, + .mipLevels = 1, + .baseArrayLayer = dest_array_slice, + .arraySize = 1 + }, }, cmd_buffer); meta_emit_blit(cmd_buffer, anv_image_from_handle(srcImage), - &src_view, + &src_iview, (VkOffset3D) { 0, 0, 0 }, pRegions[r].imageExtent, dest_image, - &dest_view, + &dest_iview, dest_offset, pRegions[r].imageExtent); @@ -1437,21 +1466,24 @@ void anv_CmdCopyImageToBuffer( VkDevice vk_device = anv_device_to_handle(cmd_buffer->device); struct anv_saved_state saved_state; - const VkImageViewType src_view_type = + const VkImageViewType src_iview_type = meta_blit_get_src_image_view_type(src_image); meta_prepare_blit(cmd_buffer, &saved_state); for (unsigned r = 0; r < regionCount; r++) { + if (pRegions[r].imageSubresource.arraySize > 1) + anv_finishme("FINISHME: copy multiple array layers"); + if (pRegions[r].imageExtent.depth > 1) anv_finishme("FINISHME: copy multiple depth layers"); - struct anv_image_view src_view; - anv_image_view_init(&src_view, cmd_buffer->device, + struct anv_image_view src_iview; + anv_image_view_init(&src_iview, cmd_buffer->device, &(VkImageViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = srcImage, - .viewType = src_view_type, + .viewType = src_iview_type, .format = src_image->format->vk_format, .channels = { VK_CHANNEL_SWIZZLE_R, @@ -1460,10 +1492,10 @@ void anv_CmdCopyImageToBuffer( VK_CHANNEL_SWIZZLE_A }, .subresourceRange = { - .aspect = pRegions[r].imageSubresource.aspect, + .aspectMask = 1 << pRegions[r].imageSubresource.aspect, .baseMipLevel = pRegions[r].imageSubresource.mipLevel, .mipLevels = 1, - .baseArraySlice = pRegions[r].imageSubresource.arraySlice, + .baseArrayLayer = pRegions[r].imageSubresource.arrayLayer, .arraySize = 1 }, }, @@ -1475,28 +1507,38 @@ void anv_CmdCopyImageToBuffer( } VkImage destImage = make_image_for_buffer(vk_device, destBuffer, - dest_format, - &pRegions[r]); + dest_format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &pRegions[r]); - struct anv_color_attachment_view dest_view; - anv_color_attachment_view_init(&dest_view, cmd_buffer->device, - &(VkAttachmentViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, + struct anv_image_view dest_iview; + anv_image_view_init(&dest_iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = destImage, + .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = dest_format, - .mipLevel = 0, - .baseArraySlice = 0, - .arraySize = 1, + .channels = { + VK_CHANNEL_SWIZZLE_R, + VK_CHANNEL_SWIZZLE_G, + VK_CHANNEL_SWIZZLE_B, + VK_CHANNEL_SWIZZLE_A + }, + .subresourceRange = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = 0, + .mipLevels = 1, + .baseArrayLayer = 0, + .arraySize = 1 + }, }, cmd_buffer); meta_emit_blit(cmd_buffer, anv_image_from_handle(srcImage), - &src_view, + &src_iview, pRegions[r].imageOffset, pRegions[r].imageExtent, anv_image_from_handle(destImage), - &dest_view, + &dest_iview, (VkOffset3D) { 0, 0, 0 }, pRegions[r].imageExtent); @@ -1538,20 +1580,33 @@ void anv_CmdClearColorImage( ANV_FROM_HANDLE(anv_image, image, _image); struct anv_saved_state saved_state; - anv_cmd_buffer_save(cmd_buffer, &saved_state); + anv_cmd_buffer_save(cmd_buffer, &saved_state, + (1 << VK_DYNAMIC_STATE_VIEWPORT)); + cmd_buffer->state.dynamic.viewport.count = 0; for (uint32_t r = 0; r < rangeCount; r++) { for (uint32_t l = 0; l < pRanges[r].mipLevels; l++) { for (uint32_t s = 0; s < pRanges[r].arraySize; s++) { - struct anv_color_attachment_view view; - anv_color_attachment_view_init(&view, cmd_buffer->device, - &(VkAttachmentViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO, + struct anv_image_view iview; + anv_image_view_init(&iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = _image, + .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = image->format->vk_format, - .mipLevel = pRanges[r].baseMipLevel + l, - .baseArraySlice = pRanges[r].baseArraySlice + s, - .arraySize = 1, + .channels = { + VK_CHANNEL_SWIZZLE_R, + VK_CHANNEL_SWIZZLE_G, + VK_CHANNEL_SWIZZLE_B, + VK_CHANNEL_SWIZZLE_A + }, + .subresourceRange = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .baseMipLevel = pRanges[r].baseMipLevel + l, + .mipLevels = 1, + .baseArrayLayer = pRanges[r].baseArrayLayer + s, + .arraySize = 1 + }, }, cmd_buffer); @@ -1560,14 +1615,11 @@ void anv_CmdClearColorImage( &(VkFramebufferCreateInfo) { .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .attachmentCount = 1, - .pAttachments = (VkAttachmentBindInfo[]) { - { - .view = anv_attachment_view_to_handle(&view.base), - .layout = VK_IMAGE_LAYOUT_GENERAL - } + .pAttachments = (VkImageView[]) { + anv_image_view_to_handle(&iview), }, - .width = view.base.extent.width, - .height = view.base.extent.height, + .width = iview.extent.width, + .height = iview.extent.height, .layers = 1 }, &fb); @@ -1578,7 +1630,7 @@ void anv_CmdClearColorImage( .attachmentCount = 1, .pAttachments = &(VkAttachmentDescription) { .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION, - .format = view.view.format->vk_format, + .format = iview.format->vk_format, .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, .storeOp = VK_ATTACHMENT_STORE_OP_STORE, .initialLayout = VK_IMAGE_LAYOUT_GENERAL, @@ -1590,17 +1642,17 @@ void anv_CmdClearColorImage( .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .inputCount = 0, .colorCount = 1, - .colorAttachments = &(VkAttachmentReference) { + .pColorAttachments = &(VkAttachmentReference) { .attachment = 0, .layout = VK_IMAGE_LAYOUT_GENERAL, }, - .resolveAttachments = NULL, + .pResolveAttachments = NULL, .depthStencilAttachment = (VkAttachmentReference) { .attachment = VK_ATTACHMENT_UNUSED, .layout = VK_IMAGE_LAYOUT_GENERAL, }, .preserveCount = 1, - .preserveAttachments = &(VkAttachmentReference) { + .pPreserveAttachments = &(VkAttachmentReference) { .attachment = 0, .layout = VK_IMAGE_LAYOUT_GENERAL, }, @@ -1614,14 +1666,14 @@ void anv_CmdClearColorImage( .renderArea = { .offset = { 0, 0, }, .extent = { - .width = view.base.extent.width, - .height = view.base.extent.height, + .width = iview.extent.width, + .height = iview.extent.height, }, }, .renderPass = pass, .framebuffer = fb, - .attachmentCount = 1, - .pAttachmentClearValues = NULL, + .clearValueCount = 1, + .pClearValues = NULL, }, VK_RENDER_PASS_CONTENTS_INLINE); struct clear_instance_data instance_data = { @@ -1649,8 +1701,7 @@ void anv_CmdClearDepthStencilImage( VkCmdBuffer cmdBuffer, VkImage image, VkImageLayout imageLayout, - float depth, - uint32_t stencil, + const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) { @@ -1670,10 +1721,9 @@ void anv_CmdClearColorAttachment( void anv_CmdClearDepthStencilAttachment( VkCmdBuffer cmdBuffer, - VkImageAspectFlags imageAspectMask, + VkImageAspectFlags aspectMask, VkImageLayout imageLayout, - float depth, - uint32_t stencil, + const VkClearDepthStencilValue* pDepthStencil, uint32_t rectCount, const VkRect3D* pRects) { @@ -1697,24 +1747,6 @@ anv_device_init_meta(struct anv_device *device) { anv_device_init_meta_clear_state(device); anv_device_init_meta_blit_state(device); - - ANV_CALL(CreateDynamicRasterState)(anv_device_to_handle(device), - &(VkDynamicRasterStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_DYNAMIC_RASTER_STATE_CREATE_INFO, - }, - &device->meta_state.shared.rs_state); - - ANV_CALL(CreateDynamicColorBlendState)(anv_device_to_handle(device), - &(VkDynamicColorBlendStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_DYNAMIC_COLOR_BLEND_STATE_CREATE_INFO - }, - &device->meta_state.shared.cb_state); - - ANV_CALL(CreateDynamicDepthStencilState)(anv_device_to_handle(device), - &(VkDynamicDepthStencilStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_DYNAMIC_DEPTH_STENCIL_STATE_CREATE_INFO - }, - &device->meta_state.shared.ds_state); } void @@ -1733,12 +1765,4 @@ anv_device_finish_meta(struct anv_device *device) device->meta_state.blit.pipeline_layout); anv_DestroyDescriptorSetLayout(anv_device_to_handle(device), device->meta_state.blit.ds_layout); - - /* Shared */ - anv_DestroyDynamicRasterState(anv_device_to_handle(device), - device->meta_state.shared.rs_state); - anv_DestroyDynamicColorBlendState(anv_device_to_handle(device), - device->meta_state.shared.cb_state); - anv_DestroyDynamicDepthStencilState(anv_device_to_handle(device), - device->meta_state.shared.ds_state); } diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c index daf520f9714..75f640154cc 100644 --- a/src/vulkan/anv_pipeline.c +++ b/src/vulkan/anv_pipeline.c @@ -56,7 +56,7 @@ VkResult anv_CreateShaderModule( return VK_SUCCESS; } -VkResult anv_DestroyShaderModule( +void anv_DestroyShaderModule( VkDevice _device, VkShaderModule _module) { @@ -64,8 +64,6 @@ VkResult anv_DestroyShaderModule( ANV_FROM_HANDLE(anv_shader_module, module, _module); anv_device_free(device, module); - - return VK_SUCCESS; } VkResult anv_CreateShader( @@ -100,7 +98,7 @@ VkResult anv_CreateShader( return VK_SUCCESS; } -VkResult anv_DestroyShader( +void anv_DestroyShader( VkDevice _device, VkShader _shader) { @@ -108,8 +106,6 @@ VkResult anv_DestroyShader( ANV_FROM_HANDLE(anv_shader, shader, _shader); anv_device_free(device, shader); - - return VK_SUCCESS; } @@ -123,12 +119,10 @@ VkResult anv_CreatePipelineCache( stub_return(VK_SUCCESS); } -VkResult anv_DestroyPipelineCache( +void anv_DestroyPipelineCache( VkDevice _device, VkPipelineCache _cache) { - /* VkPipelineCache is a dummy object. */ - return VK_SUCCESS; } size_t anv_GetPipelineCacheSize( @@ -155,7 +149,7 @@ VkResult anv_MergePipelineCaches( stub_return(VK_UNSUPPORTED); } -VkResult anv_DestroyPipeline( +void anv_DestroyPipeline( VkDevice _device, VkPipeline _pipeline) { @@ -167,8 +161,6 @@ VkResult anv_DestroyPipeline( anv_state_stream_finish(&pipeline->program_stream); anv_state_pool_free(&device->dynamic_state_pool, pipeline->blend_state); anv_device_free(pipeline->device, pipeline); - - return VK_SUCCESS; } static const uint32_t vk_to_gen_primitive_type[] = { @@ -185,6 +177,98 @@ static const uint32_t vk_to_gen_primitive_type[] = { [VK_PRIMITIVE_TOPOLOGY_PATCH] = _3DPRIM_PATCHLIST_1 }; +static void +anv_pipeline_init_dynamic_state(struct anv_pipeline *pipeline, + const VkGraphicsPipelineCreateInfo *pCreateInfo) +{ + pipeline->dynamic_state_mask = 0; + + if (pCreateInfo->pDynamicState == NULL) + return; + + uint32_t count = pCreateInfo->pDynamicState->dynamicStateCount; + struct anv_dynamic_state *dynamic = &pipeline->dynamic_state; + + for (uint32_t s = 0; s < count; s++) { + VkDynamicState state = pCreateInfo->pDynamicState->pDynamicStates[s]; + + assert(state < 32); + pipeline->dynamic_state_mask |= (1u << state); + + switch (state) { + case VK_DYNAMIC_STATE_VIEWPORT: + assert(pCreateInfo->pViewportState); + dynamic->viewport.count = pCreateInfo->pViewportState->viewportCount; + typed_memcpy(dynamic->viewport.viewports, + pCreateInfo->pViewportState->pViewports, + pCreateInfo->pViewportState->viewportCount); + break; + + case VK_DYNAMIC_STATE_SCISSOR: + assert(pCreateInfo->pViewportState); + dynamic->scissor.count = pCreateInfo->pViewportState->scissorCount; + typed_memcpy(dynamic->scissor.scissors, + pCreateInfo->pViewportState->pScissors, + pCreateInfo->pViewportState->scissorCount); + break; + + case VK_DYNAMIC_STATE_LINE_WIDTH: + assert(pCreateInfo->pRasterState); + dynamic->line_width = pCreateInfo->pRasterState->lineWidth; + break; + + case VK_DYNAMIC_STATE_DEPTH_BIAS: + assert(pCreateInfo->pRasterState); + dynamic->depth_bias.bias = pCreateInfo->pRasterState->depthBias; + dynamic->depth_bias.clamp = pCreateInfo->pRasterState->depthBiasClamp; + dynamic->depth_bias.slope_scaled = + pCreateInfo->pRasterState->slopeScaledDepthBias; + break; + + case VK_DYNAMIC_STATE_BLEND_CONSTANTS: + assert(pCreateInfo->pColorBlendState); + typed_memcpy(dynamic->blend_constants, + pCreateInfo->pColorBlendState->blendConst, 4); + break; + + case VK_DYNAMIC_STATE_DEPTH_BOUNDS: + assert(pCreateInfo->pDepthStencilState); + dynamic->depth_bounds.min = + pCreateInfo->pDepthStencilState->minDepthBounds; + dynamic->depth_bounds.max = + pCreateInfo->pDepthStencilState->maxDepthBounds; + break; + + case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK: + assert(pCreateInfo->pDepthStencilState); + dynamic->stencil_compare_mask.front = + pCreateInfo->pDepthStencilState->front.stencilCompareMask; + dynamic->stencil_compare_mask.back = + pCreateInfo->pDepthStencilState->back.stencilCompareMask; + break; + + case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK: + assert(pCreateInfo->pDepthStencilState); + dynamic->stencil_write_mask.front = + pCreateInfo->pDepthStencilState->front.stencilWriteMask; + dynamic->stencil_write_mask.back = + pCreateInfo->pDepthStencilState->back.stencilWriteMask; + break; + + case VK_DYNAMIC_STATE_STENCIL_REFERENCE: + assert(pCreateInfo->pDepthStencilState); + dynamic->stencil_reference.front = + pCreateInfo->pDepthStencilState->front.stencilReference; + dynamic->stencil_reference.back = + pCreateInfo->pDepthStencilState->back.stencilReference; + break; + + default: + assert(!"Invalid dynamic state"); + } + } +} + VkResult anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device, const VkGraphicsPipelineCreateInfo *pCreateInfo, @@ -213,11 +297,14 @@ anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device, anv_shader_from_handle(pCreateInfo->pStages[i].shader); } + anv_pipeline_init_dynamic_state(pipeline, pCreateInfo); + if (pCreateInfo->pTessellationState) anv_finishme("VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO"); if (pCreateInfo->pViewportState) anv_finishme("VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO"); - if (pCreateInfo->pMultisampleState) + if (pCreateInfo->pMultisampleState && + pCreateInfo->pMultisampleState->rasterSamples > 1) anv_finishme("VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO"); pipeline->use_repclear = extra && extra->use_repclear; @@ -418,7 +505,7 @@ VkResult anv_CreatePipelineLayout( return VK_SUCCESS; } -VkResult anv_DestroyPipelineLayout( +void anv_DestroyPipelineLayout( VkDevice _device, VkPipelineLayout _pipelineLayout) { @@ -426,6 +513,4 @@ VkResult anv_DestroyPipelineLayout( ANV_FROM_HANDLE(anv_pipeline_layout, pipeline_layout, _pipelineLayout); anv_device_free(device, pipeline_layout); - - return VK_SUCCESS; } diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index f0d288342d6..0d1998d659c 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -115,6 +115,11 @@ anv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask) (b) = __builtin_ffs(__dword) - 1, __dword; \ __dword &= ~(1 << (b))) +#define typed_memcpy(dest, src, count) ({ \ + static_assert(sizeof(*src) == sizeof(*dest), ""); \ + memcpy((dest), (src), (count) * sizeof(*(src))); \ +}) + /* Define no kernel as 1, since that's an illegal offset for a kernel */ #define NO_KERNEL 1 @@ -445,12 +450,6 @@ struct anv_meta_state { VkPipelineLayout pipeline_layout; VkDescriptorSetLayout ds_layout; } blit; - - struct { - VkDynamicRasterState rs_state; - VkDynamicColorBlendState cb_state; - VkDynamicDepthStencilState ds_state; - } shared; }; struct anv_queue { @@ -675,40 +674,6 @@ struct anv_device_memory { void * map; }; -struct anv_dynamic_vp_state { - struct anv_state sf_clip_vp; - struct anv_state cc_vp; - struct anv_state scissor; -}; - -struct anv_dynamic_rs_state { - struct { - uint32_t sf[GEN7_3DSTATE_SF_length]; - } gen7; - - struct { - uint32_t sf[GEN8_3DSTATE_SF_length]; - uint32_t raster[GEN8_3DSTATE_RASTER_length]; - } gen8; -}; - -struct anv_dynamic_ds_state { - struct { - uint32_t depth_stencil_state[GEN7_DEPTH_STENCIL_STATE_length]; - uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length]; - } gen7; - - struct { - uint32_t wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length]; - uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length]; - } gen8; -}; - -struct anv_dynamic_cb_state { - uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length]; - -}; - struct anv_descriptor_slot { int8_t dynamic_slot; uint8_t index; @@ -724,13 +689,25 @@ struct anv_descriptor_set_layout { uint32_t count; uint32_t num_dynamic_buffers; - uint32_t shader_stages; + VkShaderStageFlags shader_stages; struct anv_descriptor_slot entries[0]; }; +enum anv_descriptor_type { + ANV_DESCRIPTOR_TYPE_EMPTY = 0, + ANV_DESCRIPTOR_TYPE_BUFFER_VIEW, + ANV_DESCRIPTOR_TYPE_IMAGE_VIEW, + ANV_DESCRIPTOR_TYPE_SAMPLER, +}; + struct anv_descriptor { - struct anv_sampler *sampler; - struct anv_surface_view *view; + union { + struct anv_buffer_view *buffer_view; + struct anv_image_view *image_view; + struct anv_sampler *sampler; + }; + + enum anv_descriptor_type type; }; struct anv_descriptor_set { @@ -746,9 +723,11 @@ void anv_descriptor_set_destroy(struct anv_device *device, struct anv_descriptor_set *set); -#define MAX_VBS 32 -#define MAX_SETS 8 -#define MAX_RTS 8 +#define MAX_VBS 32 +#define MAX_SETS 8 +#define MAX_RTS 8 +#define MAX_VIEWPORTS 16 +#define MAX_SCISSORS 16 #define MAX_PUSH_CONSTANTS_SIZE 128 #define MAX_DYNAMIC_BUFFERS 16 #define MAX_IMAGES 8 @@ -781,12 +760,18 @@ struct anv_buffer { VkDeviceSize offset; }; -#define ANV_CMD_BUFFER_PIPELINE_DIRTY (1 << 0) -#define ANV_CMD_BUFFER_RS_DIRTY (1 << 2) -#define ANV_CMD_BUFFER_DS_DIRTY (1 << 3) -#define ANV_CMD_BUFFER_CB_DIRTY (1 << 4) -#define ANV_CMD_BUFFER_VP_DIRTY (1 << 5) -#define ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY (1 << 6) +/* The first 9 correspond to 1 << VK_DYNAMIC_STATE_FOO */ +#define ANV_DYNAMIC_VIEWPORT_DIRTY (1 << 0) +#define ANV_DYNAMIC_SCISSOR_DIRTY (1 << 1) +#define ANV_DYNAMIC_LINE_WIDTH_DIRTY (1 << 2) +#define ANV_DYNAMIC_DEPTH_BIAS_DIRTY (1 << 3) +#define ANV_DYNAMIC_BLEND_CONSTANTS_DIRTY (1 << 4) +#define ANV_DYNAMIC_DEPTH_BOUNDS_DIRTY (1 << 5) +#define ANV_DYNAMIC_STENCIL_COMPARE_MASK_DIRTY (1 << 6) +#define ANV_DYNAMIC_STENCIL_WRITE_MASK_DIRTY (1 << 7) +#define ANV_DYNAMIC_STENCIL_REFERENCE_DIRTY (1 << 8) +#define ANV_CMD_BUFFER_PIPELINE_DIRTY (1 << 9) +#define ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY (1 << 10) struct anv_vertex_binding { struct anv_buffer * buffer; @@ -822,32 +807,77 @@ struct anv_push_constants { struct brw_image_param images[MAX_IMAGES]; }; +struct anv_dynamic_state { + struct { + uint32_t count; + VkViewport viewports[MAX_VIEWPORTS]; + } viewport; + + struct { + uint32_t count; + VkRect2D scissors[MAX_SCISSORS]; + } scissor; + + float line_width; + + struct { + float bias; + float clamp; + float slope_scaled; + } depth_bias; + + float blend_constants[4]; + + struct { + float min; + float max; + } depth_bounds; + + struct { + uint32_t front; + uint32_t back; + } stencil_compare_mask; + + struct { + uint32_t front; + uint32_t back; + } stencil_write_mask; + + struct { + uint32_t front; + uint32_t back; + } stencil_reference; +}; + +extern const struct anv_dynamic_state default_dynamic_state; + +void anv_dynamic_state_copy(struct anv_dynamic_state *dest, + const struct anv_dynamic_state *src, + uint32_t copy_mask); + /** State required while building cmd buffer */ struct anv_cmd_state { uint32_t current_pipeline; uint32_t vb_dirty; uint32_t dirty; uint32_t compute_dirty; - uint32_t descriptors_dirty; - uint32_t push_constants_dirty; + VkShaderStageFlags descriptors_dirty; + VkShaderStageFlags push_constants_dirty; uint32_t scratch_size; struct anv_pipeline * pipeline; struct anv_pipeline * compute_pipeline; struct anv_framebuffer * framebuffer; struct anv_render_pass * pass; struct anv_subpass * subpass; - struct anv_dynamic_rs_state * rs_state; - struct anv_dynamic_ds_state * ds_state; - struct anv_dynamic_vp_state * vp_state; - struct anv_dynamic_cb_state * cb_state; uint32_t state_vf[GEN8_3DSTATE_VF_length]; struct anv_vertex_binding vertex_bindings[MAX_VBS]; struct anv_descriptor_set_binding descriptors[MAX_SETS]; struct anv_push_constants * push_constants[VK_SHADER_STAGE_NUM]; + struct anv_dynamic_state dynamic; struct { struct anv_buffer * index_buffer; - uint32_t index_type; + uint32_t index_type; /**< 3DSTATE_INDEX_BUFFER.IndexFormat */ uint32_t index_offset; } gen7; }; @@ -961,6 +991,9 @@ anv_cmd_buffer_alloc_dynamic_state(struct anv_cmd_buffer *cmd_buffer, VkResult anv_cmd_buffer_new_binding_table_block(struct anv_cmd_buffer *cmd_buffer); +void anv_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer); +void anv_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer); + void gen7_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer); void gen8_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer); @@ -982,7 +1015,7 @@ anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer, void anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer, struct anv_render_pass *pass, const VkClearValue *clear_values); -const struct anv_depth_stencil_view * +const struct anv_image_view * anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer); void anv_cmd_buffer_dump(struct anv_cmd_buffer *cmd_buffer); @@ -1013,6 +1046,9 @@ struct anv_pipeline { struct anv_batch batch; uint32_t batch_data[256]; struct anv_reloc_list batch_relocs; + uint32_t dynamic_state_mask; + struct anv_dynamic_state dynamic_state; + struct anv_shader * shaders[VK_SHADER_STAGE_NUM]; struct anv_pipeline_layout * layout; bool use_repclear; @@ -1034,7 +1070,7 @@ struct anv_pipeline { uint32_t nr_gs_entries; } urb; - uint32_t active_stages; + VkShaderStageFlags active_stages; struct anv_state_stream program_stream; struct anv_state blend_state; uint32_t vs_simd8; @@ -1154,7 +1190,7 @@ struct anv_image_view_info { bool is_cube:1; /**< RENDER_SURFACE_STATE.CubeFaceEnable* */ }; -const struct anv_image_view_info * +struct anv_image_view_info anv_image_view_info_for_vk_image_view_type(VkImageViewType type); /** @@ -1190,6 +1226,7 @@ struct anv_image { VkExtent3D extent; uint32_t levels; uint32_t array_size; + VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */ VkDeviceSize size; uint32_t alignment; @@ -1198,8 +1235,10 @@ struct anv_image { struct anv_bo *bo; VkDeviceSize offset; - /** RENDER_SURFACE_STATE.SurfaceType */ - uint8_t surf_type; + uint8_t surface_type; /**< RENDER_SURFACE_STATE.SurfaceType */ + + bool needs_nonrt_surface_state:1; + bool needs_color_rt_surface_state:1; /** * Image subsurfaces @@ -1223,42 +1262,26 @@ struct anv_image { }; }; -struct anv_surface_view { +struct anv_buffer_view { struct anv_state surface_state; /**< RENDER_SURFACE_STATE */ struct anv_bo *bo; - uint32_t offset; /**< VkBufferCreateInfo::offset */ - uint32_t range; /**< VkBufferCreateInfo::range */ - const struct anv_format *format; /**< VkBufferCreateInfo::format */ -}; - -struct anv_buffer_view { - struct anv_surface_view view; + uint32_t offset; /**< Offset into bo. */ + uint32_t range; /**< VkBufferViewCreateInfo::range */ + const struct anv_format *format; /**< VkBufferViewCreateInfo::format */ }; struct anv_image_view { - struct anv_surface_view view; - VkExtent3D extent; -}; - -enum anv_attachment_view_type { - ANV_ATTACHMENT_VIEW_TYPE_COLOR, - ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL, -}; + const struct anv_image *image; /**< VkImageViewCreateInfo::image */ + const struct anv_format *format; /**< VkImageViewCreateInfo::format */ + struct anv_bo *bo; + uint32_t offset; /**< Offset into bo. */ + VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */ -struct anv_attachment_view { - enum anv_attachment_view_type attachment_type; - VkExtent3D extent; -}; + /** RENDER_SURFACE_STATE when using image as a color render target. */ + struct anv_state color_rt_surface_state; -struct anv_color_attachment_view { - struct anv_attachment_view base; - struct anv_surface_view view; -}; - -struct anv_depth_stencil_view { - struct anv_attachment_view base; - const struct anv_image *image; /**< VkAttachmentViewCreateInfo::image */ - const struct anv_format *format; /**< VkAttachmentViewCreateInfo::format */ + /** RENDER_SURFACE_STATE when using image as a non render target. */ + struct anv_state nonrt_surface_state; }; struct anv_image_create_info { @@ -1273,10 +1296,8 @@ VkResult anv_image_create(VkDevice _device, VkImage *pImage); struct anv_surface * -anv_image_get_surface_for_aspect(struct anv_image *image, VkImageAspect aspect); - -struct anv_surface * -anv_image_get_surface_for_color_attachment(struct anv_image *image); +anv_image_get_surface_for_aspect_mask(struct anv_image *image, + VkImageAspectFlags aspect_mask); void anv_image_view_init(struct anv_image_view *view, struct anv_device *device, @@ -1295,24 +1316,9 @@ gen8_image_view_init(struct anv_image_view *iview, const VkImageViewCreateInfo* pCreateInfo, struct anv_cmd_buffer *cmd_buffer); -void anv_color_attachment_view_init(struct anv_color_attachment_view *view, - struct anv_device *device, - const VkAttachmentViewCreateInfo* pCreateInfo, - struct anv_cmd_buffer *cmd_buffer); - -void gen7_color_attachment_view_init(struct anv_color_attachment_view *aview, - struct anv_device *device, - const VkAttachmentViewCreateInfo* pCreateInfo, - struct anv_cmd_buffer *cmd_buffer); - -void gen8_color_attachment_view_init(struct anv_color_attachment_view *aview, - struct anv_device *device, - const VkAttachmentViewCreateInfo* pCreateInfo, - struct anv_cmd_buffer *cmd_buffer); - VkResult anv_buffer_view_create(struct anv_device *device, const VkBufferViewCreateInfo *pCreateInfo, - struct anv_buffer_view **view_out); + struct anv_buffer_view **bview_out); void anv_fill_buffer_surface_state(struct anv_device *device, void *state, const struct anv_format *format, @@ -1323,9 +1329,6 @@ void gen7_fill_buffer_surface_state(void *state, const struct anv_format *format void gen8_fill_buffer_surface_state(void *state, const struct anv_format *format, uint32_t offset, uint32_t range); -void anv_surface_view_fini(struct anv_device *device, - struct anv_surface_view *view); - struct anv_sampler { uint32_t state[4]; }; @@ -1335,11 +1338,8 @@ struct anv_framebuffer { uint32_t height; uint32_t layers; - /* Viewport for clears */ - VkDynamicViewportState vp_state; - uint32_t attachment_count; - const struct anv_attachment_view * attachments[0]; + const struct anv_image_view * attachments[0]; }; struct anv_subpass { @@ -1425,16 +1425,11 @@ ANV_DEFINE_HANDLE_CASTS(anv_physical_device, VkPhysicalDevice) ANV_DEFINE_HANDLE_CASTS(anv_queue, VkQueue) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool, VkCmdPool) -ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_attachment_view, VkAttachmentView) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, VkBuffer) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer_view, VkBufferView); ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set, VkDescriptorSet) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set_layout, VkDescriptorSetLayout) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_device_memory, VkDeviceMemory) -ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_cb_state, VkDynamicColorBlendState) -ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_ds_state, VkDynamicDepthStencilState) -ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_rs_state, VkDynamicRasterState) -ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_vp_state, VkDynamicViewportState) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_fence, VkFence) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_framebuffer, VkFramebuffer) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_image, VkImage) diff --git a/src/vulkan/anv_query.c b/src/vulkan/anv_query.c index 4ef9d8c4b0c..68535b40cac 100644 --- a/src/vulkan/anv_query.c +++ b/src/vulkan/anv_query.c @@ -72,7 +72,7 @@ VkResult anv_CreateQueryPool( return result; } -VkResult anv_DestroyQueryPool( +void anv_DestroyQueryPool( VkDevice _device, VkQueryPool _pool) { @@ -82,8 +82,6 @@ VkResult anv_DestroyQueryPool( anv_gem_munmap(pool->bo.map, pool->bo.size); anv_gem_close(device, pool->bo.gem_handle); anv_device_free(device, pool); - - return VK_SUCCESS; } VkResult anv_GetQueryPoolResults( @@ -122,8 +120,11 @@ VkResult anv_GetQueryPoolResults( if (flags & VK_QUERY_RESULT_WAIT_BIT) { ret = anv_gem_wait(device, pool->bo.gem_handle, &timeout); - if (ret == -1) - return vk_errorf(VK_ERROR_UNKNOWN, "gem_wait failed %m"); + if (ret == -1) { + /* We don't know the real error. */ + return vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, + "gem_wait failed %m"); + } } for (uint32_t i = 0; i < queryCount; i++) { diff --git a/src/vulkan/anv_util.c b/src/vulkan/anv_util.c index 4c8fadcc805..628e399cb3e 100644 --- a/src/vulkan/anv_util.c +++ b/src/vulkan/anv_util.c @@ -92,39 +92,20 @@ __vk_errorf(VkResult error, const char *file, int line, const char *format, ...) const char *error_str; switch ((int32_t)error) { - ERROR_CASE(VK_ERROR_UNKNOWN) - ERROR_CASE(VK_ERROR_UNAVAILABLE) - ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED) + + /* Core errors */ ERROR_CASE(VK_ERROR_OUT_OF_HOST_MEMORY) ERROR_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY) - ERROR_CASE(VK_ERROR_DEVICE_ALREADY_CREATED) + ERROR_CASE(VK_ERROR_INITIALIZATION_FAILED) ERROR_CASE(VK_ERROR_DEVICE_LOST) - ERROR_CASE(VK_ERROR_INVALID_POINTER) - ERROR_CASE(VK_ERROR_INVALID_VALUE) - ERROR_CASE(VK_ERROR_INVALID_HANDLE) - ERROR_CASE(VK_ERROR_INVALID_ORDINAL) - ERROR_CASE(VK_ERROR_INVALID_MEMORY_SIZE) - ERROR_CASE(VK_ERROR_INVALID_EXTENSION) - ERROR_CASE(VK_ERROR_INVALID_FLAGS) - ERROR_CASE(VK_ERROR_INVALID_ALIGNMENT) - ERROR_CASE(VK_ERROR_INVALID_FORMAT) - ERROR_CASE(VK_ERROR_INVALID_IMAGE) - ERROR_CASE(VK_ERROR_INVALID_DESCRIPTOR_SET_DATA) - ERROR_CASE(VK_ERROR_INVALID_QUEUE_TYPE) - ERROR_CASE(VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION) - ERROR_CASE(VK_ERROR_BAD_SHADER_CODE) - ERROR_CASE(VK_ERROR_BAD_PIPELINE_DATA) - ERROR_CASE(VK_ERROR_NOT_MAPPABLE) ERROR_CASE(VK_ERROR_MEMORY_MAP_FAILED) - ERROR_CASE(VK_ERROR_MEMORY_UNMAP_FAILED) - ERROR_CASE(VK_ERROR_INCOMPATIBLE_DEVICE) + ERROR_CASE(VK_ERROR_LAYER_NOT_PRESENT) + ERROR_CASE(VK_ERROR_EXTENSION_NOT_PRESENT) ERROR_CASE(VK_ERROR_INCOMPATIBLE_DRIVER) - ERROR_CASE(VK_ERROR_INCOMPLETE_COMMAND_BUFFER) - ERROR_CASE(VK_ERROR_BUILDING_COMMAND_BUFFER) - ERROR_CASE(VK_ERROR_MEMORY_NOT_BOUND) - ERROR_CASE(VK_ERROR_INCOMPATIBLE_QUEUE) - ERROR_CASE(VK_ERROR_INVALID_LAYER) + + /* Extension errors */ ERROR_CASE(VK_ERROR_OUT_OF_DATE_WSI) + default: assert(!"Unknown error"); error_str = "unknown error"; diff --git a/src/vulkan/anv_wsi_wayland.c b/src/vulkan/anv_wsi_wayland.c index a601ad1851f..ba3ce8a2c65 100644 --- a/src/vulkan/anv_wsi_wayland.c +++ b/src/vulkan/anv_wsi_wayland.c @@ -322,10 +322,11 @@ wsi_wl_get_surface_info(struct anv_wsi_implementation *impl, { struct wsi_wayland *wsi = (struct wsi_wayland *)impl; - if (pDataSize == NULL) - return vk_error(VK_ERROR_INVALID_POINTER); + assert(pDataSize != NULL); switch (infoType) { + default: + unreachable("bad VkSurfaceInfoTypeWSI"); case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: { VkSurfacePropertiesWSI *props = pData; @@ -384,8 +385,6 @@ wsi_wl_get_surface_info(struct anv_wsi_implementation *impl, memcpy(pData, present_modes, *pDataSize); return VK_SUCCESS; - default: - return vk_error(VK_ERROR_INVALID_VALUE); } } @@ -423,6 +422,8 @@ wsi_wl_get_swap_chain_info(struct anv_swap_chain *anv_chain, size_t size; switch (infoType) { + default: + unreachable("bad VkSwapChainInfoTypeWSI"); case VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI: { VkSwapChainImagePropertiesWSI *images = pData; @@ -441,9 +442,6 @@ wsi_wl_get_swap_chain_info(struct anv_swap_chain *anv_chain, return VK_SUCCESS; } - - default: - return vk_error(VK_ERROR_INVALID_VALUE); } } @@ -615,14 +613,16 @@ wsi_wl_image_init(struct wsi_wl_swap_chain *chain, struct wsi_wl_image *image) image->memory->bo.gem_handle, surface->stride, I915_TILING_X); if (ret) { - result = vk_error(VK_ERROR_UNKNOWN); + /* FINISHME: Choose a better error. */ + result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY); goto fail_mem; } int fd = anv_gem_handle_to_fd(chain->base.device, image->memory->bo.gem_handle); if (fd == -1) { - result = vk_error(VK_ERROR_UNKNOWN); + /* FINISHME: Choose a better error. */ + result = vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY); goto fail_mem; } @@ -769,8 +769,13 @@ anv_wl_init_wsi(struct anv_instance *instance) int ret = pthread_mutex_init(&wsi->mutex, NULL); if (ret != 0) { - result = (ret == ENOMEM) ? VK_ERROR_OUT_OF_HOST_MEMORY : - VK_ERROR_UNKNOWN; + if (ret == ENOMEM) { + result = VK_ERROR_OUT_OF_HOST_MEMORY; + } else { + /* FINISHME: Choose a better error. */ + result = VK_ERROR_OUT_OF_HOST_MEMORY; + } + goto fail_alloc; } diff --git a/src/vulkan/anv_wsi_x11.c b/src/vulkan/anv_wsi_x11.c index 03aef4cbf23..d226caf0eea 100644 --- a/src/vulkan/anv_wsi_x11.c +++ b/src/vulkan/anv_wsi_x11.c @@ -54,10 +54,11 @@ x11_get_surface_info(struct anv_wsi_implementation *impl, VkSurfaceInfoTypeWSI infoType, size_t* pDataSize, void* pData) { - if (pDataSize == NULL) - return vk_error(VK_ERROR_INVALID_POINTER); + assert(pDataSize != NULL); switch (infoType) { + default: + unreachable("bad VkSurfaceInfoTypeWSI"); case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: { VkSurfacePropertiesWSI *props = pData; @@ -77,12 +78,9 @@ x11_get_surface_info(struct anv_wsi_implementation *impl, xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(conn, cookie, &err); if (!geom) { - if (err->error_code == XCB_DRAWABLE) { - return vk_error(VK_ERROR_INVALID_HANDLE); - } else { - return vk_error(VK_ERROR_UNKNOWN); - } + /* FINISHME: Choose a more accurate error. */ free(err); + return VK_ERROR_OUT_OF_DATE_WSI; } VkExtent2D extent = { geom->width, geom->height }; @@ -122,10 +120,7 @@ x11_get_surface_info(struct anv_wsi_implementation *impl, assert(*pDataSize >= sizeof(present_modes)); memcpy(pData, present_modes, *pDataSize); - return VK_SUCCESS; - default: - return vk_error(VK_ERROR_INVALID_VALUE); } } @@ -158,6 +153,8 @@ x11_get_swap_chain_info(struct anv_swap_chain *anv_chain, size_t size; switch (infoType) { + default: + unreachable("bad VkSwapChainInfoType"); case VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI: { VkSwapChainImagePropertiesWSI *images = pData; @@ -173,12 +170,8 @@ x11_get_swap_chain_info(struct anv_swap_chain *anv_chain, images[i].image = anv_image_to_handle(chain->images[i].image); *pDataSize = size; - return VK_SUCCESS; } - - default: - return vk_error(VK_ERROR_INVALID_VALUE); } } @@ -196,13 +189,9 @@ x11_acquire_next_image(struct anv_swap_chain *anv_chain, xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(chain->conn, image->geom_cookie, &err); if (!geom) { - if (err->error_code == XCB_DRAWABLE) { - /* Probably the best thing to do if our drawable goes away */ - return vk_error(VK_ERROR_OUT_OF_DATE_WSI); - } else { - return vk_error(VK_ERROR_UNKNOWN); - } + /* Probably the best thing to do if our drawable goes away */ free(err); + return vk_error(VK_ERROR_OUT_OF_DATE_WSI); } if (geom->width != chain->extent.width || @@ -366,13 +355,17 @@ x11_create_swap_chain(struct anv_wsi_implementation *impl, int ret = anv_gem_set_tiling(device, memory->bo.gem_handle, surface->stride, I915_TILING_X); if (ret) { - result = vk_errorf(VK_ERROR_UNKNOWN, "set_tiling failed: %m"); + /* FINISHME: Choose a better error. */ + result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, + "set_tiling failed: %m"); goto fail; } int fd = anv_gem_handle_to_fd(device, memory->bo.gem_handle); if (fd == -1) { - result = vk_errorf(VK_ERROR_UNKNOWN, "handle_to_fd failed: %m"); + /* FINISHME: Choose a better error. */ + result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY, + "handle_to_fd failed: %m"); goto fail; } @@ -400,7 +393,8 @@ x11_create_swap_chain(struct anv_wsi_implementation *impl, chain->gc = xcb_generate_id(chain->conn); if (!chain->gc) { - result = vk_error(VK_ERROR_UNKNOWN); + /* FINISHME: Choose a better error. */ + result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); goto fail; } diff --git a/src/vulkan/gen7_cmd_buffer.c b/src/vulkan/gen7_cmd_buffer.c index 95d1e28698f..0106aa74aa6 100644 --- a/src/vulkan/gen7_cmd_buffer.c +++ b/src/vulkan/gen7_cmd_buffer.c @@ -256,60 +256,87 @@ gen7_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) if (cmd_buffer->state.descriptors_dirty) anv_flush_descriptor_sets(cmd_buffer); - if (cmd_buffer->state.dirty & ANV_CMD_BUFFER_VP_DIRTY) { - struct anv_dynamic_vp_state *vp_state = cmd_buffer->state.vp_state; - anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_SCISSOR_STATE_POINTERS, - .ScissorRectPointer = vp_state->scissor.offset); - anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC, - .CCViewportPointer = vp_state->cc_vp.offset); - anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, - .SFClipViewportPointer = vp_state->sf_clip_vp.offset); + if (cmd_buffer->state.dirty & ANV_DYNAMIC_VIEWPORT_DIRTY) + anv_cmd_buffer_emit_viewport(cmd_buffer); + + if (cmd_buffer->state.dirty & ANV_DYNAMIC_SCISSOR_DIRTY) + anv_cmd_buffer_emit_scissor(cmd_buffer); + + if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | + ANV_DYNAMIC_LINE_WIDTH_DIRTY | + ANV_DYNAMIC_DEPTH_BIAS_DIRTY)) { + + bool enable_bias = cmd_buffer->state.dynamic.depth_bias.bias != 0.0f || + cmd_buffer->state.dynamic.depth_bias.slope_scaled != 0.0f; + + uint32_t sf_dw[GEN8_3DSTATE_SF_length]; + struct GEN7_3DSTATE_SF sf = { + GEN7_3DSTATE_SF_header, + .LineWidth = cmd_buffer->state.dynamic.line_width, + .GlobalDepthOffsetEnableSolid = enable_bias, + .GlobalDepthOffsetEnableWireframe = enable_bias, + .GlobalDepthOffsetEnablePoint = enable_bias, + .GlobalDepthOffsetConstant = cmd_buffer->state.dynamic.depth_bias.bias, + .GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope_scaled, + .GlobalDepthOffsetClamp = cmd_buffer->state.dynamic.depth_bias.clamp + }; + GEN7_3DSTATE_SF_pack(NULL, sf_dw, &sf); + + anv_batch_emit_merge(&cmd_buffer->batch, sf_dw, pipeline->gen7.sf); } - if (cmd_buffer->state.dirty & - (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_RS_DIRTY)) { - anv_batch_emit_merge(&cmd_buffer->batch, - cmd_buffer->state.rs_state->gen7.sf, - pipeline->gen7.sf); - } + if (cmd_buffer->state.dirty & (ANV_DYNAMIC_BLEND_CONSTANTS_DIRTY | + ANV_DYNAMIC_STENCIL_REFERENCE_DIRTY)) { + struct anv_state cc_state = + anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, + GEN7_COLOR_CALC_STATE_length, 64); + struct GEN7_COLOR_CALC_STATE cc = { + .BlendConstantColorRed = cmd_buffer->state.dynamic.blend_constants[0], + .BlendConstantColorGreen = cmd_buffer->state.dynamic.blend_constants[1], + .BlendConstantColorBlue = cmd_buffer->state.dynamic.blend_constants[2], + .BlendConstantColorAlpha = cmd_buffer->state.dynamic.blend_constants[3], + .StencilReferenceValue = + cmd_buffer->state.dynamic.stencil_reference.front, + .BackFaceStencilReferenceValue = + cmd_buffer->state.dynamic.stencil_reference.back, + }; + GEN7_COLOR_CALC_STATE_pack(NULL, cc_state.map, &cc); - if (cmd_buffer->state.dirty & - (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_DS_DIRTY)) { - struct anv_state state; - - if (cmd_buffer->state.ds_state == NULL) - state = anv_cmd_buffer_emit_dynamic(cmd_buffer, - pipeline->gen7.depth_stencil_state, - GEN7_COLOR_CALC_STATE_length, 64); - else - state = anv_cmd_buffer_merge_dynamic(cmd_buffer, - cmd_buffer->state.ds_state->gen7.depth_stencil_state, - pipeline->gen7.depth_stencil_state, - GEN7_DEPTH_STENCIL_STATE_length, 64); - anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS, - .PointertoDEPTH_STENCIL_STATE = state.offset); + anv_batch_emit(&cmd_buffer->batch, + GEN7_3DSTATE_CC_STATE_POINTERS, + .ColorCalcStatePointer = cc_state.offset); } - if (cmd_buffer->state.dirty & - (ANV_CMD_BUFFER_CB_DIRTY | ANV_CMD_BUFFER_DS_DIRTY)) { - struct anv_state state; - if (cmd_buffer->state.ds_state == NULL) - state = anv_cmd_buffer_emit_dynamic(cmd_buffer, - cmd_buffer->state.cb_state->color_calc_state, - GEN7_COLOR_CALC_STATE_length, 64); - else if (cmd_buffer->state.cb_state == NULL) - state = anv_cmd_buffer_emit_dynamic(cmd_buffer, - cmd_buffer->state.ds_state->gen7.color_calc_state, - GEN7_COLOR_CALC_STATE_length, 64); - else - state = anv_cmd_buffer_merge_dynamic(cmd_buffer, - cmd_buffer->state.ds_state->gen7.color_calc_state, - cmd_buffer->state.cb_state->color_calc_state, - GEN7_COLOR_CALC_STATE_length, 64); + if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | + ANV_DYNAMIC_STENCIL_COMPARE_MASK_DIRTY | + ANV_DYNAMIC_STENCIL_WRITE_MASK_DIRTY)) { + uint32_t depth_stencil_dw[GEN7_DEPTH_STENCIL_STATE_length]; + + struct GEN7_DEPTH_STENCIL_STATE depth_stencil = { + /* Is this what we need to do? */ + .StencilBufferWriteEnable = + cmd_buffer->state.dynamic.stencil_write_mask.front != 0, + + .StencilTestMask = + cmd_buffer->state.dynamic.stencil_compare_mask.front & 0xff, + .StencilWriteMask = + cmd_buffer->state.dynamic.stencil_write_mask.front & 0xff, + + .BackfaceStencilTestMask = + cmd_buffer->state.dynamic.stencil_compare_mask.back & 0xff, + .BackfaceStencilWriteMask = + cmd_buffer->state.dynamic.stencil_write_mask.back & 0xff, + }; + GEN7_DEPTH_STENCIL_STATE_pack(NULL, depth_stencil_dw, &depth_stencil); + + struct anv_state ds_state = + anv_cmd_buffer_merge_dynamic(cmd_buffer, depth_stencil_dw, + pipeline->gen7.depth_stencil_state, + GEN7_DEPTH_STENCIL_STATE_length, 64); anv_batch_emit(&cmd_buffer->batch, - GEN7_3DSTATE_CC_STATE_POINTERS, - .ColorCalcStatePointer = state.offset); + GEN7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS, + .PointertoDEPTH_STENCIL_STATE = ds_state.offset); } if (cmd_buffer->state.gen7.index_buffer && @@ -332,10 +359,10 @@ gen7_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) void gen7_CmdDraw( VkCmdBuffer cmdBuffer, - uint32_t firstVertex, uint32_t vertexCount, - uint32_t firstInstance, - uint32_t instanceCount) + uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); struct anv_pipeline *pipeline = cmd_buffer->state.pipeline; @@ -354,11 +381,11 @@ void gen7_CmdDraw( void gen7_CmdDrawIndexed( VkCmdBuffer cmdBuffer, - uint32_t firstIndex, uint32_t indexCount, + uint32_t instanceCount, + uint32_t firstIndex, int32_t vertexOffset, - uint32_t firstInstance, - uint32_t instanceCount) + uint32_t firstInstance) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); struct anv_pipeline *pipeline = cmd_buffer->state.pipeline; @@ -529,20 +556,20 @@ static void gen7_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) { const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer; - const struct anv_depth_stencil_view *view = + const struct anv_image_view *iview = anv_cmd_buffer_get_depth_stencil_view(cmd_buffer); - const struct anv_image *image = view ? view->image : NULL; - const bool has_depth = view && view->format->depth_format; - const bool has_stencil = view && view->format->has_stencil; + const struct anv_image *image = iview ? iview->image : NULL; + const bool has_depth = iview && iview->format->depth_format; + const bool has_stencil = iview && iview->format->has_stencil; /* Emit 3DSTATE_DEPTH_BUFFER */ if (has_depth) { anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_DEPTH_BUFFER, .SurfaceType = SURFTYPE_2D, - .DepthWriteEnable = view->format->depth_format, + .DepthWriteEnable = iview->format->depth_format, .StencilWriteEnable = has_stencil, .HierarchicalDepthBufferEnable = false, - .SurfaceFormat = view->format->depth_format, + .SurfaceFormat = iview->format->depth_format, .SurfacePitch = image->depth_surface.stride - 1, .SurfaceBaseAddress = { .bo = image->bo, @@ -641,7 +668,7 @@ begin_render_pass(struct anv_cmd_buffer *cmd_buffer, .DrawingRectangleOriginX = 0); anv_cmd_buffer_clear_attachments(cmd_buffer, pass, - pRenderPassBegin->pAttachmentClearValues); + pRenderPassBegin->pClearValues); } void gen7_CmdBeginRenderPass( diff --git a/src/vulkan/gen7_pipeline.c b/src/vulkan/gen7_pipeline.c index 599432ed68a..affe04c526f 100644 --- a/src/vulkan/gen7_pipeline.c +++ b/src/vulkan/gen7_pipeline.c @@ -567,6 +567,5 @@ VkResult gen7_compute_pipeline_create( VkPipeline* pPipeline) { anv_finishme("primitive_id needs sbe swizzling setup"); - - return vk_error(VK_ERROR_UNAVAILABLE); + abort(); } diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index faf99a5aef8..d317fa4ec16 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -65,20 +65,20 @@ VkResult gen7_CreateBufferView( VkBufferView* pView) { ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_buffer_view *view; + struct anv_buffer_view *bview; VkResult result; - result = anv_buffer_view_create(device, pCreateInfo, &view); + result = anv_buffer_view_create(device, pCreateInfo, &bview); if (result != VK_SUCCESS) return result; const struct anv_format *format = anv_format_for_vk_format(pCreateInfo->format); - gen7_fill_buffer_surface_state(view->view.surface_state.map, format, - view->view.offset, pCreateInfo->range); + gen7_fill_buffer_surface_state(bview->surface_state.map, format, + bview->offset, pCreateInfo->range); - *pView = anv_buffer_view_to_handle(view); + *pView = anv_buffer_view_to_handle(bview); return VK_SUCCESS; } @@ -95,11 +95,11 @@ static const uint32_t vk_to_gen_mipmap_mode[] = { }; static const uint32_t vk_to_gen_tex_address[] = { - [VK_TEX_ADDRESS_WRAP] = TCM_WRAP, - [VK_TEX_ADDRESS_MIRROR] = TCM_MIRROR, - [VK_TEX_ADDRESS_CLAMP] = TCM_CLAMP, - [VK_TEX_ADDRESS_MIRROR_ONCE] = TCM_MIRROR_ONCE, - [VK_TEX_ADDRESS_CLAMP_BORDER] = TCM_CLAMP_BORDER, + [VK_TEX_ADDRESS_MODE_WRAP] = TCM_WRAP, + [VK_TEX_ADDRESS_MODE_MIRROR] = TCM_MIRROR, + [VK_TEX_ADDRESS_MODE_CLAMP] = TCM_CLAMP, + [VK_TEX_ADDRESS_MODE_MIRROR_ONCE] = TCM_MIRROR_ONCE, + [VK_TEX_ADDRESS_MODE_CLAMP_BORDER] = TCM_CLAMP_BORDER, }; static const uint32_t vk_to_gen_compare_op[] = { @@ -113,6 +113,18 @@ static const uint32_t vk_to_gen_compare_op[] = { [VK_COMPARE_OP_ALWAYS] = PREFILTEROPALWAYS, }; +static struct anv_state +gen7_alloc_surface_state(struct anv_device *device, + struct anv_cmd_buffer *cmd_buffer) +{ + if (cmd_buffer) { + return anv_state_stream_alloc(&cmd_buffer->surface_state_stream, + 64, 64); + } else { + return anv_state_pool_alloc(&device->surface_state_pool, 64, 64); + } +} + VkResult gen7_CreateSampler( VkDevice _device, const VkSamplerCreateInfo* pCreateInfo, @@ -168,10 +180,10 @@ VkResult gen7_CreateSampler( .UAddressMinFilterRoundingEnable = 0, .UAddressMagFilterRoundingEnable = 0, .TrilinearFilterQuality = 0, - .NonnormalizedCoordinateEnable = 0, - .TCXAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressU], - .TCYAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressV], - .TCZAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressW], + .NonnormalizedCoordinateEnable = pCreateInfo->unnormalizedCoordinates, + .TCXAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeU], + .TCYAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeV], + .TCZAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeW], }; GEN7_SAMPLER_STATE_pack(NULL, sampler->state, &sampler_state); @@ -180,78 +192,6 @@ VkResult gen7_CreateSampler( return VK_SUCCESS; } -VkResult gen7_CreateDynamicRasterState( - VkDevice _device, - const VkDynamicRasterStateCreateInfo* pCreateInfo, - VkDynamicRasterState* pState) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_dynamic_rs_state *state; - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_RASTER_STATE_CREATE_INFO); - - state = anv_device_alloc(device, sizeof(*state), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (state == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - bool enable_bias = pCreateInfo->depthBias != 0.0f || - pCreateInfo->slopeScaledDepthBias != 0.0f; - - struct GEN7_3DSTATE_SF sf = { - GEN7_3DSTATE_SF_header, - .LineWidth = pCreateInfo->lineWidth, - .GlobalDepthOffsetEnableSolid = enable_bias, - .GlobalDepthOffsetEnableWireframe = enable_bias, - .GlobalDepthOffsetEnablePoint = enable_bias, - .GlobalDepthOffsetConstant = pCreateInfo->depthBias, - .GlobalDepthOffsetScale = pCreateInfo->slopeScaledDepthBias, - .GlobalDepthOffsetClamp = pCreateInfo->depthBiasClamp - }; - - GEN7_3DSTATE_SF_pack(NULL, state->gen7.sf, &sf); - - *pState = anv_dynamic_rs_state_to_handle(state); - - return VK_SUCCESS; -} - -VkResult gen7_CreateDynamicDepthStencilState( - VkDevice _device, - const VkDynamicDepthStencilStateCreateInfo* pCreateInfo, - VkDynamicDepthStencilState* pState) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_dynamic_ds_state *state; - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_DEPTH_STENCIL_STATE_CREATE_INFO); - - state = anv_device_alloc(device, sizeof(*state), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (state == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - struct GEN7_DEPTH_STENCIL_STATE depth_stencil_state = { - .StencilTestMask = pCreateInfo->stencilReadMask & 0xff, - .StencilWriteMask = pCreateInfo->stencilWriteMask & 0xff, - .BackfaceStencilTestMask = pCreateInfo->stencilReadMask & 0xff, - .BackfaceStencilWriteMask = pCreateInfo->stencilWriteMask & 0xff, - }; - - GEN7_DEPTH_STENCIL_STATE_pack(NULL, state->gen7.depth_stencil_state, - &depth_stencil_state); - - struct GEN7_COLOR_CALC_STATE color_calc_state = { - .StencilReferenceValue = pCreateInfo->stencilFrontRef, - .BackFaceStencilReferenceValue = pCreateInfo->stencilBackRef - }; - - GEN7_COLOR_CALC_STATE_pack(NULL, state->gen7.color_calc_state, &color_calc_state); - - *pState = anv_dynamic_ds_state_to_handle(state); - - return VK_SUCCESS; -} static const uint8_t anv_halign[] = { [4] = HALIGN_4, @@ -272,22 +212,20 @@ gen7_image_view_init(struct anv_image_view *iview, ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange; - struct anv_surface_view *view = &iview->view; + struct anv_surface *surface = - anv_image_get_surface_for_aspect(image, range->aspect); + anv_image_get_surface_for_aspect_mask(image, range->aspectMask); const struct anv_format *format = anv_format_for_vk_format(pCreateInfo->format); - const struct anv_image_view_info *view_type_info = - anv_image_view_info_for_vk_image_view_type(pCreateInfo->viewType); - if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D) anv_finishme("non-2D image views"); - view->bo = image->bo; - view->offset = image->offset + surface->offset; - view->format = anv_format_for_vk_format(pCreateInfo->format); + iview->image = image; + iview->bo = image->bo; + iview->offset = image->offset + surface->offset; + iview->format = anv_format_for_vk_format(pCreateInfo->format); iview->extent = (VkExtent3D) { .width = anv_minify(image->extent.width, range->baseMipLevel), @@ -303,7 +241,7 @@ gen7_image_view_init(struct anv_image_view *iview, } struct GEN7_RENDER_SURFACE_STATE surface_state = { - .SurfaceType = view_type_info->surface_type, + .SurfaceType = image->surface_type, .SurfaceArray = image->array_size > 1, .SurfaceFormat = format->surface_format, .SurfaceVerticalAlignment = anv_valign[surface->v_align], @@ -317,27 +255,22 @@ gen7_image_view_init(struct anv_image_view *iview, .VerticalLineStride = 0, .VerticalLineStrideOffset = 0, - .RenderCacheReadWriteMode = false, + + .RenderCacheReadWriteMode = 0, /* TEMPLATE */ .Height = image->extent.height - 1, .Width = image->extent.width - 1, .Depth = depth - 1, .SurfacePitch = surface->stride - 1, - .MinimumArrayElement = range->baseArraySlice, + .MinimumArrayElement = range->baseArrayLayer, .NumberofMultisamples = MULTISAMPLECOUNT_1, .XOffset = 0, .YOffset = 0, .SurfaceObjectControlState = GEN7_MOCS, - /* For render target surfaces, the hardware interprets field MIPCount/LOD as - * LOD. The Broadwell PRM says: - * - * MIPCountLOD defines the LOD that will be rendered into. - * SurfaceMinLOD is ignored. - */ - .MIPCountLOD = range->mipLevels - 1, - .SurfaceMinLOD = range->baseMipLevel, + .MIPCountLOD = 0, /* TEMPLATE */ + .SurfaceMinLOD = 0, /* TEMPLATE */ .MCSEnable = false, .RedClearColor = 0, @@ -345,89 +278,31 @@ gen7_image_view_init(struct anv_image_view *iview, .BlueClearColor = 0, .AlphaClearColor = 0, .ResourceMinLOD = 0.0, - .SurfaceBaseAddress = { NULL, view->offset }, + .SurfaceBaseAddress = { NULL, iview->offset }, }; - if (cmd_buffer) { - view->surface_state = - anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64); - } else { - view->surface_state = - anv_state_pool_alloc(&device->surface_state_pool, 64, 64); - } + if (image->needs_nonrt_surface_state) { + iview->nonrt_surface_state = + gen7_alloc_surface_state(device, cmd_buffer); - GEN7_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state); -} + surface_state.RenderCacheReadWriteMode = false; -void -gen7_color_attachment_view_init(struct anv_color_attachment_view *aview, - struct anv_device *device, - const VkAttachmentViewCreateInfo* pCreateInfo, - struct anv_cmd_buffer *cmd_buffer) -{ - ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); - struct anv_surface_view *view = &aview->view; - struct anv_surface *surface = - anv_image_get_surface_for_color_attachment(image); - - aview->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_COLOR; - - anv_assert(pCreateInfo->arraySize > 0); - anv_assert(pCreateInfo->mipLevel < image->levels); - anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size); - - view->bo = image->bo; - view->offset = image->offset + surface->offset; - view->format = anv_format_for_vk_format(pCreateInfo->format); - - aview->base.extent = (VkExtent3D) { - .width = anv_minify(image->extent.width, pCreateInfo->mipLevel), - .height = anv_minify(image->extent.height, pCreateInfo->mipLevel), - .depth = anv_minify(image->extent.depth, pCreateInfo->mipLevel), - }; - - uint32_t depth = 1; - if (pCreateInfo->arraySize > 1) { - depth = pCreateInfo->arraySize; - } else if (image->extent.depth > 1) { - depth = image->extent.depth; - } - - if (cmd_buffer) { - view->surface_state = - anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64); - } else { - view->surface_state = - anv_state_pool_alloc(&device->surface_state_pool, 64, 64); - } - - struct GEN7_RENDER_SURFACE_STATE surface_state = { - .SurfaceType = SURFTYPE_2D, - .SurfaceArray = image->array_size > 1, - .SurfaceFormat = view->format->surface_format, - .SurfaceVerticalAlignment = anv_valign[surface->v_align], - .SurfaceHorizontalAlignment = anv_halign[surface->h_align], - - /* From bspec (DevSNB, DevIVB): "Set Tile Walk to TILEWALK_XMAJOR if - * Tiled Surface is False." + /* For non render target surfaces, the hardware interprets field + * MIPCount/LOD as MIPCount. The range of levels accessible by the + * sampler engine is [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD]. */ - .TiledSurface = surface->tile_mode > LINEAR, - .TileWalk = surface->tile_mode == YMAJOR ? TILEWALK_YMAJOR : TILEWALK_XMAJOR, + surface_state.SurfaceMinLOD = range->baseMipLevel; + surface_state.MIPCountLOD = range->mipLevels - 1; - .VerticalLineStride = 0, - .VerticalLineStrideOffset = 0, - .RenderCacheReadWriteMode = WriteOnlyCache, + GEN7_RENDER_SURFACE_STATE_pack(NULL, iview->nonrt_surface_state.map, + &surface_state); + } - .Height = image->extent.height - 1, - .Width = image->extent.width - 1, - .Depth = depth - 1, - .SurfacePitch = surface->stride - 1, - .MinimumArrayElement = pCreateInfo->baseArraySlice, - .NumberofMultisamples = MULTISAMPLECOUNT_1, - .XOffset = 0, - .YOffset = 0, + if (image->needs_color_rt_surface_state) { + iview->color_rt_surface_state = + gen7_alloc_surface_state(device, cmd_buffer); - .SurfaceObjectControlState = GEN7_MOCS, + surface_state.RenderCacheReadWriteMode = WriteOnlyCache; /* For render target surfaces, the hardware interprets field MIPCount/LOD as * LOD. The Broadwell PRM says: @@ -435,18 +310,10 @@ gen7_color_attachment_view_init(struct anv_color_attachment_view *aview, * MIPCountLOD defines the LOD that will be rendered into. * SurfaceMinLOD is ignored. */ - .SurfaceMinLOD = 0, - .MIPCountLOD = pCreateInfo->mipLevel, + surface_state.MIPCountLOD = range->baseMipLevel; + surface_state.SurfaceMinLOD = 0; - .MCSEnable = false, - .RedClearColor = 0, - .GreenClearColor = 0, - .BlueClearColor = 0, - .AlphaClearColor = 0, - .ResourceMinLOD = 0.0, - .SurfaceBaseAddress = { NULL, view->offset }, - - }; - - GEN7_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state); + GEN7_RENDER_SURFACE_STATE_pack(NULL, iview->color_rt_surface_state.map, + &surface_state); + } } diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c index 0e830b4427d..a1db0170c09 100644 --- a/src/vulkan/gen8_cmd_buffer.c +++ b/src/vulkan/gen8_cmd_buffer.c @@ -32,8 +32,6 @@ static void gen8_cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer) { - uint32_t stage; - static const uint32_t push_constant_opcodes[] = { [VK_SHADER_STAGE_VERTEX] = 21, [VK_SHADER_STAGE_TESS_CONTROL] = 25, /* HS */ @@ -43,7 +41,8 @@ gen8_cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer) [VK_SHADER_STAGE_COMPUTE] = 0, }; - uint32_t flushed = 0; + VkShaderStage stage; + VkShaderStageFlags flushed = 0; for_each_bit(stage, cmd_buffer->state.push_constants_dirty) { struct anv_state state = anv_cmd_buffer_push_constants(cmd_buffer, stage); @@ -122,58 +121,96 @@ gen8_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) if (cmd_buffer->state.push_constants_dirty) gen8_cmd_buffer_flush_push_constants(cmd_buffer); - if (cmd_buffer->state.dirty & ANV_CMD_BUFFER_VP_DIRTY) { - struct anv_dynamic_vp_state *vp_state = cmd_buffer->state.vp_state; - anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_SCISSOR_STATE_POINTERS, - .ScissorRectPointer = vp_state->scissor.offset); - anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_CC, - .CCViewportPointer = vp_state->cc_vp.offset); - anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, - .SFClipViewportPointer = vp_state->sf_clip_vp.offset); - } + if (cmd_buffer->state.dirty & ANV_DYNAMIC_VIEWPORT_DIRTY) + anv_cmd_buffer_emit_viewport(cmd_buffer); + + if (cmd_buffer->state.dirty & ANV_DYNAMIC_SCISSOR_DIRTY) + anv_cmd_buffer_emit_scissor(cmd_buffer); if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | - ANV_CMD_BUFFER_RS_DIRTY)) { - anv_batch_emit_merge(&cmd_buffer->batch, - cmd_buffer->state.rs_state->gen8.sf, - pipeline->gen8.sf); - anv_batch_emit_merge(&cmd_buffer->batch, - cmd_buffer->state.rs_state->gen8.raster, - pipeline->gen8.raster); + ANV_DYNAMIC_LINE_WIDTH_DIRTY)) { + uint32_t sf_dw[GEN8_3DSTATE_SF_length]; + struct GEN8_3DSTATE_SF sf = { + GEN8_3DSTATE_SF_header, + .LineWidth = cmd_buffer->state.dynamic.line_width, + }; + GEN8_3DSTATE_SF_pack(NULL, sf_dw, &sf); + anv_batch_emit_merge(&cmd_buffer->batch, sf_dw, pipeline->gen8.sf); } - if (cmd_buffer->state.ds_state && - (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | - ANV_CMD_BUFFER_DS_DIRTY))) { - anv_batch_emit_merge(&cmd_buffer->batch, - cmd_buffer->state.ds_state->gen8.wm_depth_stencil, - pipeline->gen8.wm_depth_stencil); + if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | + ANV_DYNAMIC_DEPTH_BIAS_DIRTY)) { + bool enable_bias = cmd_buffer->state.dynamic.depth_bias.bias != 0.0f || + cmd_buffer->state.dynamic.depth_bias.slope_scaled != 0.0f; + + uint32_t raster_dw[GEN8_3DSTATE_RASTER_length]; + struct GEN8_3DSTATE_RASTER raster = { + GEN8_3DSTATE_RASTER_header, + .GlobalDepthOffsetEnableSolid = enable_bias, + .GlobalDepthOffsetEnableWireframe = enable_bias, + .GlobalDepthOffsetEnablePoint = enable_bias, + .GlobalDepthOffsetConstant = cmd_buffer->state.dynamic.depth_bias.bias, + .GlobalDepthOffsetScale = cmd_buffer->state.dynamic.depth_bias.slope_scaled, + .GlobalDepthOffsetClamp = cmd_buffer->state.dynamic.depth_bias.clamp + }; + GEN8_3DSTATE_RASTER_pack(NULL, raster_dw, &raster); + anv_batch_emit_merge(&cmd_buffer->batch, raster_dw, + pipeline->gen8.raster); } - if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_CB_DIRTY | - ANV_CMD_BUFFER_DS_DIRTY)) { - struct anv_state state; - if (cmd_buffer->state.ds_state == NULL) - state = anv_cmd_buffer_emit_dynamic(cmd_buffer, - cmd_buffer->state.cb_state->color_calc_state, - GEN8_COLOR_CALC_STATE_length, 64); - else if (cmd_buffer->state.cb_state == NULL) - state = anv_cmd_buffer_emit_dynamic(cmd_buffer, - cmd_buffer->state.ds_state->gen8.color_calc_state, - GEN8_COLOR_CALC_STATE_length, 64); - else - state = anv_cmd_buffer_merge_dynamic(cmd_buffer, - cmd_buffer->state.ds_state->gen8.color_calc_state, - cmd_buffer->state.cb_state->color_calc_state, - GEN8_COLOR_CALC_STATE_length, 64); + if (cmd_buffer->state.dirty & (ANV_DYNAMIC_BLEND_CONSTANTS_DIRTY | + ANV_DYNAMIC_STENCIL_REFERENCE_DIRTY)) { + struct anv_state cc_state = + anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, + GEN8_COLOR_CALC_STATE_length, 64); + struct GEN8_COLOR_CALC_STATE cc = { + .BlendConstantColorRed = cmd_buffer->state.dynamic.blend_constants[0], + .BlendConstantColorGreen = cmd_buffer->state.dynamic.blend_constants[1], + .BlendConstantColorBlue = cmd_buffer->state.dynamic.blend_constants[2], + .BlendConstantColorAlpha = cmd_buffer->state.dynamic.blend_constants[3], + .StencilReferenceValue = + cmd_buffer->state.dynamic.stencil_reference.front, + .BackFaceStencilReferenceValue = + cmd_buffer->state.dynamic.stencil_reference.back, + }; + GEN8_COLOR_CALC_STATE_pack(NULL, cc_state.map, &cc); anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_CC_STATE_POINTERS, - .ColorCalcStatePointer = state.offset, + .ColorCalcStatePointer = cc_state.offset, .ColorCalcStatePointerValid = true); } if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | + ANV_DYNAMIC_STENCIL_COMPARE_MASK_DIRTY | + ANV_DYNAMIC_STENCIL_WRITE_MASK_DIRTY)) { + uint32_t wm_depth_stencil_dw[GEN8_3DSTATE_WM_DEPTH_STENCIL_length]; + + struct GEN8_3DSTATE_WM_DEPTH_STENCIL wm_depth_stencil = { + GEN8_3DSTATE_WM_DEPTH_STENCIL_header, + + /* Is this what we need to do? */ + .StencilBufferWriteEnable = + cmd_buffer->state.dynamic.stencil_write_mask.front != 0, + + .StencilTestMask = + cmd_buffer->state.dynamic.stencil_compare_mask.front & 0xff, + .StencilWriteMask = + cmd_buffer->state.dynamic.stencil_write_mask.front & 0xff, + + .BackfaceStencilTestMask = + cmd_buffer->state.dynamic.stencil_compare_mask.back & 0xff, + .BackfaceStencilWriteMask = + cmd_buffer->state.dynamic.stencil_write_mask.back & 0xff, + }; + GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, wm_depth_stencil_dw, + &wm_depth_stencil); + + anv_batch_emit_merge(&cmd_buffer->batch, wm_depth_stencil_dw, + pipeline->gen8.wm_depth_stencil); + } + + if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY)) { anv_batch_emit_merge(&cmd_buffer->batch, cmd_buffer->state.state_vf, pipeline->gen8.vf); @@ -185,10 +222,10 @@ gen8_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) void gen8_CmdDraw( VkCmdBuffer cmdBuffer, - uint32_t firstVertex, uint32_t vertexCount, - uint32_t firstInstance, - uint32_t instanceCount) + uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); @@ -205,11 +242,11 @@ void gen8_CmdDraw( void gen8_CmdDrawIndexed( VkCmdBuffer cmdBuffer, - uint32_t firstIndex, uint32_t indexCount, + uint32_t instanceCount, + uint32_t firstIndex, int32_t vertexOffset, - uint32_t firstInstance, - uint32_t instanceCount) + uint32_t firstInstance) { ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); @@ -459,11 +496,11 @@ static void gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) { const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer; - const struct anv_depth_stencil_view *view = + const struct anv_image_view *iview = anv_cmd_buffer_get_depth_stencil_view(cmd_buffer); - const struct anv_image *image = view ? view->image : NULL; - const bool has_depth = view && view->format->depth_format; - const bool has_stencil = view && view->format->has_stencil; + const struct anv_image *image = iview ? iview->image : NULL; + const bool has_depth = iview && iview->format->depth_format; + const bool has_stencil = iview && iview->format->has_stencil; /* FIXME: Implement the PMA stall W/A */ /* FIXME: Width and Height are wrong */ @@ -472,10 +509,10 @@ gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) if (has_depth) { anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_DEPTH_BUFFER, .SurfaceType = SURFTYPE_2D, - .DepthWriteEnable = view->format->depth_format, + .DepthWriteEnable = iview->format->depth_format, .StencilWriteEnable = has_stencil, .HierarchicalDepthBufferEnable = false, - .SurfaceFormat = view->format->depth_format, + .SurfaceFormat = iview->format->depth_format, .SurfacePitch = image->depth_surface.stride - 1, .SurfaceBaseAddress = { .bo = image->bo, @@ -580,7 +617,7 @@ void gen8_CmdBeginRenderPass( .DrawingRectangleOriginX = 0); anv_cmd_buffer_clear_attachments(cmd_buffer, pass, - pRenderPassBegin->pAttachmentClearValues); + pRenderPassBegin->pClearValues); gen8_cmd_buffer_begin_subpass(cmd_buffer, pass->subpasses); } @@ -936,8 +973,7 @@ void gen8_CmdPipelineBarrier( if (anv_clear_mask(&srcStageMask, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | - VK_PIPELINE_STAGE_TRANSFER_BIT | - VK_PIPELINE_STAGE_TRANSITION_BIT)) { + VK_PIPELINE_STAGE_TRANSFER_BIT)) { cmd.CommandStreamerStallEnable = true; } diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c index fae09f3fbbe..0e2526fce20 100644 --- a/src/vulkan/gen8_pipeline.c +++ b/src/vulkan/gen8_pipeline.c @@ -269,7 +269,7 @@ emit_ds_state(struct anv_pipeline *pipeline, return; } - /* VkBool32 depthBoundsEnable; // optional (depth_bounds_test) */ + /* VkBool32 depthBoundsTestEnable; // optional (depth_bounds_test) */ struct GEN8_3DSTATE_WM_DEPTH_STENCIL wm_depth_stencil = { .DepthTestEnable = info->depthTestEnable, @@ -571,7 +571,7 @@ VkResult gen8_compute_pipeline_create( memset(pipeline->shaders, 0, sizeof(pipeline->shaders)); pipeline->shaders[VK_SHADER_STAGE_COMPUTE] = - anv_shader_from_handle(pCreateInfo->cs.shader); + anv_shader_from_handle(pCreateInfo->stage.shader); pipeline->use_repclear = false; diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index 5646637e4a0..9be3bf46021 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -29,46 +29,6 @@ #include "anv_private.h" -VkResult gen8_CreateDynamicRasterState( - VkDevice _device, - const VkDynamicRasterStateCreateInfo* pCreateInfo, - VkDynamicRasterState* pState) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_dynamic_rs_state *state; - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_RASTER_STATE_CREATE_INFO); - - state = anv_device_alloc(device, sizeof(*state), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (state == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - struct GEN8_3DSTATE_SF sf = { - GEN8_3DSTATE_SF_header, - .LineWidth = pCreateInfo->lineWidth, - }; - - GEN8_3DSTATE_SF_pack(NULL, state->gen8.sf, &sf); - - bool enable_bias = pCreateInfo->depthBias != 0.0f || - pCreateInfo->slopeScaledDepthBias != 0.0f; - struct GEN8_3DSTATE_RASTER raster = { - .GlobalDepthOffsetEnableSolid = enable_bias, - .GlobalDepthOffsetEnableWireframe = enable_bias, - .GlobalDepthOffsetEnablePoint = enable_bias, - .GlobalDepthOffsetConstant = pCreateInfo->depthBias, - .GlobalDepthOffsetScale = pCreateInfo->slopeScaledDepthBias, - .GlobalDepthOffsetClamp = pCreateInfo->depthBiasClamp - }; - - GEN8_3DSTATE_RASTER_pack(NULL, state->gen8.raster, &raster); - - *pState = anv_dynamic_rs_state_to_handle(state); - - return VK_SUCCESS; -} - void gen8_fill_buffer_surface_state(void *state, const struct anv_format *format, uint32_t offset, uint32_t range) @@ -109,20 +69,20 @@ VkResult gen8_CreateBufferView( VkBufferView* pView) { ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_buffer_view *view; + struct anv_buffer_view *bview; VkResult result; - result = anv_buffer_view_create(device, pCreateInfo, &view); + result = anv_buffer_view_create(device, pCreateInfo, &bview); if (result != VK_SUCCESS) return result; const struct anv_format *format = anv_format_for_vk_format(pCreateInfo->format); - gen8_fill_buffer_surface_state(view->view.surface_state.map, format, - view->view.offset, pCreateInfo->range); + gen8_fill_buffer_surface_state(bview->surface_state.map, format, + bview->offset, pCreateInfo->range); - *pView = anv_buffer_view_to_handle(view); + *pView = anv_buffer_view_to_handle(bview); return VK_SUCCESS; } @@ -139,6 +99,18 @@ static const uint8_t anv_valign[] = { [16] = VALIGN16, }; +static struct anv_state +gen8_alloc_surface_state(struct anv_device *device, + struct anv_cmd_buffer *cmd_buffer) +{ + if (cmd_buffer) { + return anv_state_stream_alloc(&cmd_buffer->surface_state_stream, + 64, 64); + } else { + return anv_state_pool_alloc(&device->surface_state_pool, 64, 64); + } +} + void gen8_image_view_init(struct anv_image_view *iview, struct anv_device *device, @@ -148,9 +120,9 @@ gen8_image_view_init(struct anv_image_view *iview, ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange; - struct anv_surface_view *view = &iview->view; + struct anv_surface *surface = - anv_image_get_surface_for_aspect(image, range->aspect); + anv_image_get_surface_for_aspect_mask(image, range->aspectMask); uint32_t depth = 1; /* RENDER_SURFACE_STATE::Depth */ uint32_t rt_view_extent = 1; /* RENDER_SURFACE_STATE::RenderTargetViewExtent */ @@ -158,12 +130,10 @@ gen8_image_view_init(struct anv_image_view *iview, const struct anv_format *format_info = anv_format_for_vk_format(pCreateInfo->format); - const struct anv_image_view_info *view_type_info = - anv_image_view_info_for_vk_image_view_type(pCreateInfo->viewType); - - view->bo = image->bo; - view->offset = image->offset + surface->offset; - view->format = format_info; + iview->image = image; + iview->bo = image->bo; + iview->offset = image->offset + surface->offset; + iview->format = format_info; iview->extent = (VkExtent3D) { .width = anv_minify(image->extent.width, range->baseMipLevel), @@ -220,7 +190,7 @@ gen8_image_view_init(struct anv_image_view *iview, }; struct GEN8_RENDER_SURFACE_STATE surface_state = { - .SurfaceType = view_type_info->surface_type, + .SurfaceType = image->surface_type, .SurfaceArray = image->array_size > 1, .SurfaceFormat = format_info->surface_format, .SurfaceVerticalAlignment = anv_valign[surface->v_align], @@ -244,17 +214,13 @@ gen8_image_view_init(struct anv_image_view *iview, .Depth = depth - 1, .SurfacePitch = surface->stride - 1, .RenderTargetViewExtent = rt_view_extent - 1, - .MinimumArrayElement = range->baseArraySlice, + .MinimumArrayElement = range->baseArrayLayer, .NumberofMultisamples = MULTISAMPLECOUNT_1, .XOffset = 0, .YOffset = 0, - /* For sampler surfaces, the hardware interprets field MIPCount/LOD as - * MIPCount. The range of levels accessible by the sampler engine is - * [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD]. - */ - .MIPCountLOD = range->mipLevels - 1, - .SurfaceMinLOD = range->baseMipLevel, + .MIPCountLOD = 0, /* TEMPLATE */ + .SurfaceMinLOD = 0, /* TEMPLATE */ .AuxiliarySurfaceMode = AUX_NONE, .RedClearColor = 0, @@ -266,152 +232,40 @@ gen8_image_view_init(struct anv_image_view *iview, .ShaderChannelSelectBlue = vk_to_gen_swizzle[pCreateInfo->channels.b], .ShaderChannelSelectAlpha = vk_to_gen_swizzle[pCreateInfo->channels.a], .ResourceMinLOD = 0.0, - .SurfaceBaseAddress = { NULL, view->offset }, + .SurfaceBaseAddress = { NULL, iview->offset }, }; - if (cmd_buffer) { - view->surface_state = - anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64); - } else { - view->surface_state = - anv_state_pool_alloc(&device->surface_state_pool, 64, 64); - } - - GEN8_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state); -} + if (image->needs_nonrt_surface_state) { + iview->nonrt_surface_state = + gen8_alloc_surface_state(device, cmd_buffer); -void -gen8_color_attachment_view_init(struct anv_color_attachment_view *aview, - struct anv_device *device, - const VkAttachmentViewCreateInfo* pCreateInfo, - struct anv_cmd_buffer *cmd_buffer) -{ - ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); - struct anv_surface_view *view = &aview->view; - struct anv_surface *surface = - anv_image_get_surface_for_color_attachment(image); - const struct anv_format *format_info = - anv_format_for_vk_format(pCreateInfo->format); - - uint32_t depth = 1; /* RENDER_SURFACE_STATE::Depth */ - uint32_t rt_view_extent = 1; /* RENDER_SURFACE_STATE::RenderTargetViewExtent */ - - aview->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_COLOR; - - anv_assert(pCreateInfo->arraySize > 0); - anv_assert(pCreateInfo->mipLevel < image->levels); - anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size); - - view->bo = image->bo; - view->offset = image->offset + surface->offset; - view->format = anv_format_for_vk_format(pCreateInfo->format); - - aview->base.extent = (VkExtent3D) { - .width = anv_minify(image->extent.width, pCreateInfo->mipLevel), - .height = anv_minify(image->extent.height, pCreateInfo->mipLevel), - .depth = anv_minify(image->extent.depth, pCreateInfo->mipLevel), - }; - - switch (image->type) { - case VK_IMAGE_TYPE_1D: - case VK_IMAGE_TYPE_2D: - /* From the Broadwell PRM >> RENDER_SURFACE_STATE::Depth: - * - * For SURFTYPE_1D, 2D, and CUBE: The range of this field is reduced - * by one for each increase from zero of Minimum Array Element. For - * example, if Minimum Array Element is set to 1024 on a 2D surface, - * the range of this field is reduced to [0,1023]. - */ - depth = pCreateInfo->arraySize; - - /* From the Broadwell PRM >> RENDER_SURFACE_STATE::RenderTargetViewExtent: - * - * For Render Target and Typed Dataport 1D and 2D Surfaces: - * This field must be set to the same value as the Depth field. + /* For non render target surfaces, the hardware interprets field + * MIPCount/LOD as MIPCount. The range of levels accessible by the + * sampler engine is [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD]. */ - rt_view_extent = depth; - break; - case VK_IMAGE_TYPE_3D: - /* From the Broadwell PRM >> RENDER_SURFACE_STATE::Depth: - * - * If the volume texture is MIP-mapped, this field specifies the - * depth of the base MIP level. - */ - depth = image->extent.depth; + surface_state.SurfaceMinLOD = range->baseMipLevel; + surface_state.MIPCountLOD = range->mipLevels - 1; - /* From the Broadwell PRM >> RENDER_SURFACE_STATE::RenderTargetViewExtent: - * - * For Render Target and Typed Dataport 3D Surfaces: This field - * indicates the extent of the accessible 'R' coordinates minus 1 on - * the LOD currently being rendered to. - */ - rt_view_extent = aview->base.extent.depth; - break; - default: - unreachable(!"bad VkImageType"); + GEN8_RENDER_SURFACE_STATE_pack(NULL, iview->nonrt_surface_state.map, + &surface_state); } - if (cmd_buffer) { - view->surface_state = - anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64); - } else { - view->surface_state = - anv_state_pool_alloc(&device->surface_state_pool, 64, 64); - } - - struct GEN8_RENDER_SURFACE_STATE surface_state = { - .SurfaceType = image->type, - .SurfaceArray = image->array_size > 1, - .SurfaceFormat = format_info->surface_format, - .SurfaceVerticalAlignment = anv_valign[surface->v_align], - .SurfaceHorizontalAlignment = anv_halign[surface->h_align], - .TileMode = surface->tile_mode, - .VerticalLineStride = 0, - .VerticalLineStrideOffset = 0, - .SamplerL2BypassModeDisable = true, - .RenderCacheReadWriteMode = WriteOnlyCache, - .MemoryObjectControlState = GEN8_MOCS, - - /* The driver sets BaseMipLevel in SAMPLER_STATE, not here in - * RENDER_SURFACE_STATE. The Broadwell PRM says "it is illegal to have - * both Base Mip Level fields nonzero". - */ - .BaseMipLevel = 0.0, - - .SurfaceQPitch = surface->qpitch >> 2, - .Height = image->extent.height - 1, - .Width = image->extent.width - 1, - .Depth = depth - 1, - .SurfacePitch = surface->stride - 1, - .RenderTargetViewExtent = rt_view_extent - 1, - .MinimumArrayElement = pCreateInfo->baseArraySlice, - .NumberofMultisamples = MULTISAMPLECOUNT_1, - .XOffset = 0, - .YOffset = 0, + if (image->needs_color_rt_surface_state) { + iview->color_rt_surface_state = + gen8_alloc_surface_state(device, cmd_buffer); - /* For render target surfaces, the hardware interprets field MIPCount/LOD as - * LOD. The Broadwell PRM says: + /* For render target surfaces, the hardware interprets field + * MIPCount/LOD as LOD. The Broadwell PRM says: * * MIPCountLOD defines the LOD that will be rendered into. * SurfaceMinLOD is ignored. */ - .SurfaceMinLOD = 0, - .MIPCountLOD = pCreateInfo->mipLevel, + surface_state.MIPCountLOD = range->baseMipLevel; + surface_state.SurfaceMinLOD = 0; - .AuxiliarySurfaceMode = AUX_NONE, - .RedClearColor = 0, - .GreenClearColor = 0, - .BlueClearColor = 0, - .AlphaClearColor = 0, - .ShaderChannelSelectRed = SCS_RED, - .ShaderChannelSelectGreen = SCS_GREEN, - .ShaderChannelSelectBlue = SCS_BLUE, - .ShaderChannelSelectAlpha = SCS_ALPHA, - .ResourceMinLOD = 0.0, - .SurfaceBaseAddress = { NULL, view->offset }, - }; - - GEN8_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state); + GEN8_RENDER_SURFACE_STATE_pack(NULL, iview->color_rt_surface_state.map, + &surface_state); + } } VkResult gen8_CreateSampler( @@ -442,11 +296,11 @@ VkResult gen8_CreateSampler( }; static const uint32_t vk_to_gen_tex_address[] = { - [VK_TEX_ADDRESS_WRAP] = TCM_WRAP, - [VK_TEX_ADDRESS_MIRROR] = TCM_MIRROR, - [VK_TEX_ADDRESS_CLAMP] = TCM_CLAMP, - [VK_TEX_ADDRESS_MIRROR_ONCE] = TCM_MIRROR_ONCE, - [VK_TEX_ADDRESS_CLAMP_BORDER] = TCM_CLAMP_BORDER, + [VK_TEX_ADDRESS_MODE_WRAP] = TCM_WRAP, + [VK_TEX_ADDRESS_MODE_MIRROR] = TCM_MIRROR, + [VK_TEX_ADDRESS_MODE_CLAMP] = TCM_CLAMP, + [VK_TEX_ADDRESS_MODE_MIRROR_ONCE] = TCM_MIRROR_ONCE, + [VK_TEX_ADDRESS_MODE_CLAMP_BORDER] = TCM_CLAMP_BORDER, }; static const uint32_t vk_to_gen_compare_op[] = { @@ -501,10 +355,10 @@ VkResult gen8_CreateSampler( .UAddressMinFilterRoundingEnable = 0, .UAddressMagFilterRoundingEnable = 0, .TrilinearFilterQuality = 0, - .NonnormalizedCoordinateEnable = 0, - .TCXAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressU], - .TCYAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressV], - .TCZAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressW], + .NonnormalizedCoordinateEnable = pCreateInfo->unnormalizedCoordinates, + .TCXAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeU], + .TCYAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeV], + .TCZAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeW], }; GEN8_SAMPLER_STATE_pack(NULL, sampler->state, &sampler_state); @@ -513,46 +367,3 @@ VkResult gen8_CreateSampler( return VK_SUCCESS; } - -VkResult gen8_CreateDynamicDepthStencilState( - VkDevice _device, - const VkDynamicDepthStencilStateCreateInfo* pCreateInfo, - VkDynamicDepthStencilState* pState) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_dynamic_ds_state *state; - - assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DYNAMIC_DEPTH_STENCIL_STATE_CREATE_INFO); - - state = anv_device_alloc(device, sizeof(*state), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (state == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - - struct GEN8_3DSTATE_WM_DEPTH_STENCIL wm_depth_stencil = { - GEN8_3DSTATE_WM_DEPTH_STENCIL_header, - - /* Is this what we need to do? */ - .StencilBufferWriteEnable = pCreateInfo->stencilWriteMask != 0, - - .StencilTestMask = pCreateInfo->stencilReadMask & 0xff, - .StencilWriteMask = pCreateInfo->stencilWriteMask & 0xff, - - .BackfaceStencilTestMask = pCreateInfo->stencilReadMask & 0xff, - .BackfaceStencilWriteMask = pCreateInfo->stencilWriteMask & 0xff, - }; - - GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, state->gen8.wm_depth_stencil, - &wm_depth_stencil); - - struct GEN8_COLOR_CALC_STATE color_calc_state = { - .StencilReferenceValue = pCreateInfo->stencilFrontRef, - .BackFaceStencilReferenceValue = pCreateInfo->stencilBackRef - }; - - GEN8_COLOR_CALC_STATE_pack(NULL, state->gen8.color_calc_state, &color_calc_state); - - *pState = anv_dynamic_ds_state_to_handle(state); - - return VK_SUCCESS; -} |