#include "vkrenderframework.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \
- { \
- fp##entrypoint = \
- (PFN_vk##entrypoint)vkGetDeviceProcAddr(dev, "vk" #entrypoint); \
- assert(fp##entrypoint != NULL); \
+#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \
+ { \
+ fp##entrypoint = (PFN_vk##entrypoint)vkGetDeviceProcAddr(dev, "vk" #entrypoint); \
+ assert(fp##entrypoint != NULL); \
}
// TODO : These functions are duplicated is vk_layer_utils.cpp, share code
}
// Return true if format is a stencil-only format
-bool vk_format_is_stencil_only(VkFormat format) {
- return (format == VK_FORMAT_S8_UINT);
-}
+bool vk_format_is_stencil_only(VkFormat format) { return (format == VK_FORMAT_S8_UINT); }
// Return true if format is a depth-only format
bool vk_format_is_depth_only(VkFormat format) {
}
VkRenderFramework::VkRenderFramework()
- : inst(VK_NULL_HANDLE), m_device(NULL), m_commandPool(VK_NULL_HANDLE),
- m_commandBuffer(NULL), m_renderPass(VK_NULL_HANDLE),
+ : inst(VK_NULL_HANDLE), m_device(NULL), m_commandPool(VK_NULL_HANDLE), m_commandBuffer(NULL), m_renderPass(VK_NULL_HANDLE),
m_framebuffer(VK_NULL_HANDLE), m_width(256.0), // default window width
m_height(256.0), // default window height
- m_render_target_fmt(VK_FORMAT_R8G8B8A8_UNORM),
- m_depth_stencil_fmt(VK_FORMAT_UNDEFINED), m_clear_via_load_op(true),
- m_depth_clear_color(1.0), m_stencil_clear_color(0), m_depthStencil(NULL),
- m_CreateDebugReportCallback(VK_NULL_HANDLE),
- m_DestroyDebugReportCallback(VK_NULL_HANDLE),
- m_globalMsgCallback(VK_NULL_HANDLE), m_devMsgCallback(VK_NULL_HANDLE) {
+ m_render_target_fmt(VK_FORMAT_R8G8B8A8_UNORM), m_depth_stencil_fmt(VK_FORMAT_UNDEFINED), m_clear_via_load_op(true),
+ m_depth_clear_color(1.0), m_stencil_clear_color(0), m_depthStencil(NULL), m_CreateDebugReportCallback(VK_NULL_HANDLE),
+ m_DestroyDebugReportCallback(VK_NULL_HANDLE), m_globalMsgCallback(VK_NULL_HANDLE), m_devMsgCallback(VK_NULL_HANDLE) {
memset(&m_renderPassBeginInfo, 0, sizeof(m_renderPassBeginInfo));
m_renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
#ifdef _WIN32
- instance_extension_names.push_back(
- VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
+ instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif
- InitFramework(instance_layer_names, instance_extension_names,
- device_extension_names);
+ InitFramework(instance_layer_names, instance_extension_names, device_extension_names);
}
-void VkRenderFramework::InitFramework(
- std::vector<const char *> instance_layer_names,
- std::vector<const char *> instance_extension_names,
- std::vector<const char *> device_extension_names,
- PFN_vkDebugReportCallbackEXT dbgFunction, void *userData) {
+void VkRenderFramework::InitFramework(std::vector<const char *> instance_layer_names,
+ std::vector<const char *> instance_extension_names,
+ std::vector<const char *> device_extension_names, PFN_vkDebugReportCallbackEXT dbgFunction,
+ void *userData) {
VkInstanceCreateInfo instInfo = {};
std::vector<VkExtensionProperties> instance_extensions;
std::vector<VkExtensionProperties> device_extensions;
ASSERT_GE(this->gpu_count, (uint32_t)1) << "No GPU available";
if (dbgFunction) {
m_CreateDebugReportCallback =
- (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(
- this->inst, "vkCreateDebugReportCallbackEXT");
- ASSERT_NE(m_CreateDebugReportCallback,
- (PFN_vkCreateDebugReportCallbackEXT)NULL)
+ (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(this->inst, "vkCreateDebugReportCallbackEXT");
+ ASSERT_NE(m_CreateDebugReportCallback, (PFN_vkCreateDebugReportCallbackEXT)NULL)
<< "Did not get function pointer for CreateDebugReportCallback";
if (m_CreateDebugReportCallback) {
VkDebugReportCallbackCreateInfoEXT dbgCreateInfo;
memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
- dbgCreateInfo.sType =
- VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
- dbgCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT |
- VK_DEBUG_REPORT_WARNING_BIT_EXT |
- VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
+ dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
+ dbgCreateInfo.flags =
+ VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
dbgCreateInfo.pfnCallback = dbgFunction;
dbgCreateInfo.pUserData = userData;
- err = m_CreateDebugReportCallback(this->inst, &dbgCreateInfo, NULL,
- &m_globalMsgCallback);
+ err = m_CreateDebugReportCallback(this->inst, &dbgCreateInfo, NULL, &m_globalMsgCallback);
ASSERT_VK_SUCCESS(err);
m_DestroyDebugReportCallback =
- (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(
- this->inst, "vkDestroyDebugReportCallbackEXT");
- ASSERT_NE(m_DestroyDebugReportCallback,
- (PFN_vkDestroyDebugReportCallbackEXT)NULL)
+ (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(this->inst, "vkDestroyDebugReportCallbackEXT");
+ ASSERT_NE(m_DestroyDebugReportCallback, (PFN_vkDestroyDebugReportCallbackEXT)NULL)
<< "Did not get function pointer for "
"DestroyDebugReportCallback";
- m_DebugReportMessage =
- (PFN_vkDebugReportMessageEXT)vkGetInstanceProcAddr(
- this->inst, "vkDebugReportMessageEXT");
+ m_DebugReportMessage = (PFN_vkDebugReportMessageEXT)vkGetInstanceProcAddr(this->inst, "vkDebugReportMessageEXT");
ASSERT_NE(m_DebugReportMessage, (PFN_vkDebugReportMessageEXT)NULL)
<< "Did not get function pointer for DebugReportMessage";
}
m_DestroyDebugReportCallback(this->inst, m_devMsgCallback, NULL);
while (!m_renderTargets.empty()) {
- vkDestroyImageView(
- device(), m_renderTargets.back()->targetView(m_render_target_fmt),
- NULL);
+ vkDestroyImageView(device(), m_renderTargets.back()->targetView(m_render_target_fmt), NULL);
vkDestroyImage(device(), m_renderTargets.back()->image(), NULL);
vkFreeMemory(device(), m_renderTargets.back()->memory(), NULL);
m_renderTargets.pop_back();
m_reference = 0;
VkCommandPoolCreateInfo cmd_pool_info;
- cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
- cmd_pool_info.pNext = NULL,
+ cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, cmd_pool_info.pNext = NULL,
cmd_pool_info.queueFamilyIndex = m_device->graphics_queue_node_index_;
- cmd_pool_info.flags = 0,
- err = vkCreateCommandPool(device(), &cmd_pool_info, NULL, &m_commandPool);
+ cmd_pool_info.flags = 0, err = vkCreateCommandPool(device(), &cmd_pool_info, NULL, &m_commandPool);
assert(!err);
m_commandBuffer = new VkCommandBufferObj(m_device, m_commandPool);
void VkRenderFramework::InitViewport() { InitViewport(m_width, m_height); }
void VkRenderFramework::InitRenderTarget() { InitRenderTarget(1); }
-void VkRenderFramework::InitRenderTarget(uint32_t targets) {
- InitRenderTarget(targets, NULL);
-}
+void VkRenderFramework::InitRenderTarget(uint32_t targets) { InitRenderTarget(targets, NULL); }
-void VkRenderFramework::InitRenderTarget(VkImageView *dsBinding) {
- InitRenderTarget(1, dsBinding);
-}
+void VkRenderFramework::InitRenderTarget(VkImageView *dsBinding) { InitRenderTarget(1, dsBinding); }
-void VkRenderFramework::InitRenderTarget(uint32_t targets,
- VkImageView *dsBinding) {
+void VkRenderFramework::InitRenderTarget(uint32_t targets, VkImageView *dsBinding) {
std::vector<VkAttachmentDescription> attachments;
std::vector<VkAttachmentReference> color_references;
std::vector<VkImageView> bindings;
VkAttachmentDescription att = {};
att.format = m_render_target_fmt;
att.samples = VK_SAMPLE_COUNT_1_BIT;
- att.loadOp = (m_clear_via_load_op) ? VK_ATTACHMENT_LOAD_OP_CLEAR
- : VK_ATTACHMENT_LOAD_OP_LOAD;
+ att.loadOp = (m_clear_via_load_op) ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD;
att.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
VkFormatProperties props;
- vkGetPhysicalDeviceFormatProperties(m_device->phy().handle(),
- m_render_target_fmt, &props);
-
- if (props.linearTilingFeatures &
- VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
- img->init((uint32_t)m_width, (uint32_t)m_height,
- m_render_target_fmt, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
- VK_IMAGE_TILING_LINEAR);
- } else if (props.optimalTilingFeatures &
- VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
- img->init((uint32_t)m_width, (uint32_t)m_height,
- m_render_target_fmt, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
- VK_IMAGE_TILING_OPTIMAL);
+ vkGetPhysicalDeviceFormatProperties(m_device->phy().handle(), m_render_target_fmt, &props);
+
+ if (props.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
+ img->init((uint32_t)m_width, (uint32_t)m_height, m_render_target_fmt,
+ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_LINEAR);
+ } else if (props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
+ img->init((uint32_t)m_width, (uint32_t)m_height, m_render_target_fmt,
+ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_OPTIMAL);
} else {
FAIL() << "Neither Linear nor Optimal allowed for render target";
}
VkAttachmentReference ds_reference;
if (dsBinding) {
att.format = m_depth_stencil_fmt;
- att.loadOp = (m_clear_via_load_op) ? VK_ATTACHMENT_LOAD_OP_CLEAR
- : VK_ATTACHMENT_LOAD_OP_LOAD;
+ att.loadOp = (m_clear_via_load_op) ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD;
;
att.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
m_renderPassBeginInfo.pClearValues = m_renderPassClearValues.data();
}
-VkDeviceObj::VkDeviceObj(uint32_t id, VkPhysicalDevice obj)
- : vk_testing::Device(obj), id(id) {
+VkDeviceObj::VkDeviceObj(uint32_t id, VkPhysicalDevice obj) : vk_testing::Device(obj), id(id) {
init();
props = phy().properties();
queue_props = phy().queue_properties();
}
-VkDeviceObj::VkDeviceObj(uint32_t id, VkPhysicalDevice obj,
- std::vector<const char *> &extension_names,
+VkDeviceObj::VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<const char *> &extension_names,
VkPhysicalDeviceFeatures *features)
: vk_testing::Device(obj), id(id) {
init(extension_names, features);
m_queue = graphics_queues()[0]->handle();
}
-VkDescriptorSetObj::VkDescriptorSetObj(VkDeviceObj *device)
- : m_device(device), m_nextSlot(0) {}
+VkDescriptorSetObj::VkDescriptorSetObj(VkDeviceObj *device) : m_device(device), m_nextSlot(0) {}
VkDescriptorSetObj::~VkDescriptorSetObj() {
if (m_set) {
return m_nextSlot++;
}
-int VkDescriptorSetObj::AppendBuffer(VkDescriptorType type,
- VkConstantBufferObj &constantBuffer) {
- assert(type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
- type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
- type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER ||
- type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC);
+int VkDescriptorSetObj::AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer) {
+ assert(type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
+ type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER || type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC);
VkDescriptorSetLayoutBinding binding = {};
binding.descriptorType = type;
binding.descriptorCount = 1;
m_layout_bindings.push_back(binding);
m_type_counts[type] += binding.descriptorCount;
- m_writes.push_back(vk_testing::Device::write_descriptor_set(
- vk_testing::DescriptorSet(), m_nextSlot, 0, type, 1,
- &constantBuffer.m_descriptorBufferInfo));
+ m_writes.push_back(vk_testing::Device::write_descriptor_set(vk_testing::DescriptorSet(), m_nextSlot, 0, type, 1,
+ &constantBuffer.m_descriptorBufferInfo));
return m_nextSlot++;
}
-int VkDescriptorSetObj::AppendSamplerTexture(VkSamplerObj *sampler,
- VkTextureObj *texture) {
+int VkDescriptorSetObj::AppendSamplerTexture(VkSamplerObj *sampler, VkTextureObj *texture) {
VkDescriptorSetLayoutBinding binding = {};
binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
binding.descriptorCount = 1;
binding.pImmutableSamplers = NULL;
m_layout_bindings.push_back(binding);
- m_type_counts[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] +=
- binding.descriptorCount;
+ m_type_counts[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] += binding.descriptorCount;
VkDescriptorImageInfo tmp = texture->m_imageInfo;
tmp.sampler = sampler->handle();
m_imageSamplerDescriptors.push_back(tmp);
- m_writes.push_back(vk_testing::Device::write_descriptor_set(
- vk_testing::DescriptorSet(), m_nextSlot, 0,
- VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &tmp));
+ m_writes.push_back(vk_testing::Device::write_descriptor_set(vk_testing::DescriptorSet(), m_nextSlot, 0,
+ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &tmp));
return m_nextSlot++;
}
-VkPipelineLayout VkDescriptorSetObj::GetPipelineLayout() const {
- return m_pipeline_layout.handle();
-}
+VkPipelineLayout VkDescriptorSetObj::GetPipelineLayout() const { return m_pipeline_layout.handle(); }
-VkDescriptorSet VkDescriptorSetObj::GetDescriptorSetHandle() const {
- return m_set->handle();
-}
+VkDescriptorSet VkDescriptorSetObj::GetDescriptorSetHandle() const { return m_set->handle(); }
-void VkDescriptorSetObj::CreateVKDescriptorSet(
- VkCommandBufferObj *commandBuffer) {
+void VkDescriptorSetObj::CreateVKDescriptorSet(VkCommandBufferObj *commandBuffer) {
- if ( m_type_counts.size()) {
+ if (m_type_counts.size()) {
// create VkDescriptorPool
VkDescriptorPoolSize poolSize;
vector<VkDescriptorPoolSize> sizes;
// build the update array
size_t imageSamplerCount = 0;
- for (std::vector<VkWriteDescriptorSet>::iterator it = m_writes.begin();
- it != m_writes.end(); it++) {
+ for (std::vector<VkWriteDescriptorSet>::iterator it = m_writes.begin(); it != m_writes.end(); it++) {
it->dstSet = m_set->handle();
if (it->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
it->pImageInfo = &m_imageSamplerDescriptors[imageSamplerCount++];
vkCreateRenderPass(device, &rpci, NULL, &m_renderpass);
}
-VkRenderpassObj::~VkRenderpassObj() {
- vkDestroyRenderPass(device, m_renderpass, NULL);
-}
+VkRenderpassObj::~VkRenderpassObj() { vkDestroyRenderPass(device, m_renderpass, NULL); }
VkImageObj::VkImageObj(VkDeviceObj *dev) {
m_device = dev;
m_descriptorImageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
}
-void VkImageObj::ImageMemoryBarrier(VkCommandBufferObj *cmd_buf,
- VkImageAspectFlags aspect,
- VkFlags output_mask /*=
+void VkImageObj::ImageMemoryBarrier(VkCommandBufferObj *cmd_buf, VkImageAspectFlags aspect, VkFlags output_mask /*=
VK_ACCESS_HOST_WRITE_BIT |
VK_ACCESS_SHADER_WRITE_BIT |
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
VK_ACCESS_SHADER_READ_BIT |
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
- VK_MEMORY_INPUT_COPY_BIT*/,
- VkImageLayout image_layout) {
- const VkImageSubresourceRange subresourceRange =
- subresource_range(aspect, 0, 1, 0, 1);
+ VK_MEMORY_INPUT_COPY_BIT*/, VkImageLayout image_layout) {
+ const VkImageSubresourceRange subresourceRange = subresource_range(aspect, 0, 1, 0, 1);
VkImageMemoryBarrier barrier;
- barrier = image_memory_barrier(output_mask, input_mask, layout(),
- image_layout, subresourceRange);
+ barrier = image_memory_barrier(output_mask, input_mask, layout(), image_layout, subresourceRange);
VkImageMemoryBarrier *pmemory_barrier = &barrier;
VkPipelineStageFlags dest_stages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
// write barrier to the command buffer
- vkCmdPipelineBarrier(cmd_buf->handle(), src_stages, dest_stages, 0, 0, NULL,
- 0, NULL, 1, pmemory_barrier);
+ vkCmdPipelineBarrier(cmd_buf->handle(), src_stages, dest_stages, 0, 0, NULL, 0, NULL, 1, pmemory_barrier);
}
-void VkImageObj::SetLayout(VkCommandBufferObj *cmd_buf,
- VkImageAspectFlags aspect,
- VkImageLayout image_layout) {
+void VkImageObj::SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspectFlags aspect, VkImageLayout image_layout) {
VkFlags src_mask, dst_mask;
- const VkFlags all_cache_outputs =
- VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_TRANSFER_WRITE_BIT;
- const VkFlags all_cache_inputs =
- VK_ACCESS_HOST_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT |
- VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT |
- VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_MEMORY_READ_BIT;
+ const VkFlags all_cache_outputs = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
+ const VkFlags all_cache_inputs = VK_ACCESS_HOST_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_INDEX_READ_BIT |
+ VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT |
+ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
+ VK_ACCESS_MEMORY_READ_BIT;
if (image_layout == m_descriptorImageInfo.imageLayout) {
return;
switch (image_layout) {
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
- if (m_descriptorImageInfo.imageLayout ==
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
+ if (m_descriptorImageInfo.imageLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
src_mask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
else
src_mask = VK_ACCESS_TRANSFER_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
- if (m_descriptorImageInfo.imageLayout ==
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
+ if (m_descriptorImageInfo.imageLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
src_mask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
- else if (m_descriptorImageInfo.imageLayout ==
- VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
+ else if (m_descriptorImageInfo.imageLayout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
src_mask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
else
src_mask = VK_ACCESS_TRANSFER_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
- if (m_descriptorImageInfo.imageLayout ==
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
+ if (m_descriptorImageInfo.imageLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
src_mask = VK_ACCESS_TRANSFER_WRITE_BIT;
else
src_mask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
break;
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
- if (m_descriptorImageInfo.imageLayout ==
- VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
+ if (m_descriptorImageInfo.imageLayout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
src_mask = VK_ACCESS_TRANSFER_READ_BIT;
else
src_mask = 0;
m_descriptorImageInfo.imageLayout = image_layout;
}
-void VkImageObj::SetLayout(VkImageAspectFlags aspect,
- VkImageLayout image_layout) {
+void VkImageObj::SetLayout(VkImageAspectFlags aspect, VkImageLayout image_layout) {
VkResult U_ASSERT_ONLY err;
if (image_layout == m_descriptorImageInfo.imageLayout) {
}
bool VkImageObj::IsCompatible(VkFlags usage, VkFlags features) {
- if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) &&
- !(features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
+ if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) && !(features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
return false;
return true;
}
-void VkImageObj::init_no_layout(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage,
- VkImageTiling requested_tiling,
- VkMemoryPropertyFlags reqs) {
+void VkImageObj::init_no_layout(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage, VkImageTiling requested_tiling,
+ VkMemoryPropertyFlags reqs) {
VkFormatProperties image_fmt;
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
- vkGetPhysicalDeviceFormatProperties(m_device->phy().handle(), fmt,
- &image_fmt);
+ vkGetPhysicalDeviceFormatProperties(m_device->phy().handle(), fmt, &image_fmt);
if (requested_tiling == VK_IMAGE_TILING_LINEAR) {
if (IsCompatible(usage, image_fmt.linearTilingFeatures)) {
} else if (IsCompatible(usage, image_fmt.optimalTilingFeatures)) {
tiling = VK_IMAGE_TILING_OPTIMAL;
} else {
- ASSERT_TRUE(false)
- << "Error: Cannot find requested tiling configuration";
+ ASSERT_TRUE(false) << "Error: Cannot find requested tiling configuration";
}
} else if (IsCompatible(usage, image_fmt.optimalTilingFeatures)) {
tiling = VK_IMAGE_TILING_OPTIMAL;
} else if (IsCompatible(usage, image_fmt.linearTilingFeatures)) {
tiling = VK_IMAGE_TILING_LINEAR;
} else {
- ASSERT_TRUE(false)
- << "Error: Cannot find requested tiling configuration";
+ ASSERT_TRUE(false) << "Error: Cannot find requested tiling configuration";
}
VkImageCreateInfo imageCreateInfo = vk_testing::Image::create_info();
vk_testing::Image::init(*m_device, imageCreateInfo, reqs);
}
-void VkImageObj::init(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage,
- VkImageTiling requested_tiling,
+void VkImageObj::init(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage, VkImageTiling requested_tiling,
VkMemoryPropertyFlags reqs) {
init_no_layout(w, h, fmt, usage, requested_tiling, reqs);
/* TODO: Can we determine image aspect from image object? */
src_image_layout = src_image.layout();
- src_image.SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT,
- VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
+ src_image.SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
- dest_image_layout = (this->layout() == VK_IMAGE_LAYOUT_UNDEFINED)?
- VK_IMAGE_LAYOUT_GENERAL:this->layout();
- this->SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
+ dest_image_layout = (this->layout() == VK_IMAGE_LAYOUT_UNDEFINED) ? VK_IMAGE_LAYOUT_GENERAL : this->layout();
+ this->SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
VkImageCopy copy_region = {};
copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copy_region.dstOffset.z = 0;
copy_region.extent = src_image.extent();
- vkCmdCopyImage(cmd_buf.handle(), src_image.handle(), src_image.layout(),
- handle(), layout(), 1, ©_region);
+ vkCmdCopyImage(cmd_buf.handle(), src_image.handle(), src_image.layout(), handle(), layout(), 1, ©_region);
src_image.SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, src_image_layout);
return VK_SUCCESS;
}
-VkTextureObj::VkTextureObj(VkDeviceObj *device, uint32_t *colors)
- : VkImageObj(device) {
+VkTextureObj::VkTextureObj(VkDeviceObj *device, uint32_t *colors) : VkImageObj(device) {
m_device = device;
const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM;
uint32_t tex_colors[2] = {0xffff0000, 0xff00ff00};
void *data;
uint32_t x, y;
VkImageObj stagingImage(device);
- VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
- VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
+ VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
- stagingImage.init(16, 16, tex_format, VK_IMAGE_USAGE_TRANSFER_DST_BIT |
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
- VK_IMAGE_TILING_LINEAR, reqs);
- VkSubresourceLayout layout = stagingImage.subresource_layout(
- subresource(VK_IMAGE_ASPECT_COLOR_BIT, 0, 0));
+ stagingImage.init(16, 16, tex_format, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_LINEAR,
+ reqs);
+ VkSubresourceLayout layout = stagingImage.subresource_layout(subresource(VK_IMAGE_ASPECT_COLOR_BIT, 0, 0));
if (colors == NULL)
colors = tex_colors;
view.subresourceRange.layerCount = 1;
/* create image */
- init(16, 16, tex_format,
- VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
- VK_IMAGE_TILING_OPTIMAL);
+ init(16, 16, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL);
stagingImage.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
/* create image view */
* Basic ConstantBuffer constructor. Then use create methods to fill in the
* details.
*/
-VkConstantBufferObj::VkConstantBufferObj(VkDeviceObj *device,
- VkBufferUsageFlags usage) {
+VkConstantBufferObj::VkConstantBufferObj(VkDeviceObj *device, VkBufferUsageFlags usage) {
m_device = device;
m_commandBuffer = 0;
memset(&m_descriptorBufferInfo, 0, sizeof(m_descriptorBufferInfo));
// Special case for usages outside of original limits of framework
- if ((VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT) !=
- usage) {
+ if ((VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT) != usage) {
init_no_mem(*m_device, create_info(0, usage));
}
}
}
}
-VkConstantBufferObj::VkConstantBufferObj(VkDeviceObj *device, int constantCount,
- int constantSize, const void *data,
+VkConstantBufferObj::VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void *data,
VkBufferUsageFlags usage) {
m_device = device;
m_commandBuffer = 0;
m_numVertices = constantCount;
m_stride = constantSize;
- VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
- VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
- const VkDeviceSize allocationSize =
- static_cast<VkDeviceSize>(constantCount * constantSize);
+ VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
+ const VkDeviceSize allocationSize = static_cast<VkDeviceSize>(constantCount * constantSize);
- if ((VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT) ==
- usage) {
+ if ((VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT) == usage) {
init_as_src_and_dst(*m_device, allocationSize, reqs);
} else {
init(*m_device, create_info(allocationSize, usage), reqs);
this->m_descriptorBufferInfo.range = allocationSize;
}
-void VkConstantBufferObj::Bind(VkCommandBuffer commandBuffer,
- VkDeviceSize offset, uint32_t binding) {
+void VkConstantBufferObj::Bind(VkCommandBuffer commandBuffer, VkDeviceSize offset, uint32_t binding) {
vkCmdBindVertexBuffers(commandBuffer, binding, 1, &handle(), &offset);
}
VK_ACCESS_SHADER_WRITE_BIT |
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_MEMORY_OUTPUT_COPY_BIT*/,
- VkFlags dstAccessMask /*=
+ VK_MEMORY_OUTPUT_COPY_BIT*/, VkFlags dstAccessMask /*=
VK_ACCESS_HOST_READ_BIT |
VK_ACCESS_INDIRECT_COMMAND_READ_BIT |
VK_ACCESS_INDEX_READ_BIT |
cmd_pool_info.queueFamilyIndex = m_device->graphics_queue_node_index_;
cmd_pool_info.flags = 0;
m_commandPool = new vk_testing::CommandPool(*m_device, cmd_pool_info);
- m_commandBuffer =
- new VkCommandBufferObj(m_device, m_commandPool->handle());
+ m_commandBuffer = new VkCommandBufferObj(m_device, m_commandPool->handle());
} else {
m_device->wait(m_fence);
}
err = m_commandBuffer->BeginCommandBuffer(&cmd_buf_info);
ASSERT_VK_SUCCESS(err);
- VkBufferMemoryBarrier memory_barrier = buffer_memory_barrier(
- srcAccessMask, dstAccessMask, 0, m_numVertices * m_stride);
+ VkBufferMemoryBarrier memory_barrier = buffer_memory_barrier(srcAccessMask, dstAccessMask, 0, m_numVertices * m_stride);
VkBufferMemoryBarrier *pmemory_barrier = &memory_barrier;
VkPipelineStageFlags src_stages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
VkPipelineStageFlags dest_stages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
// write barrier to the command buffer
- m_commandBuffer->PipelineBarrier(src_stages, dest_stages, 0, 0, NULL, 1,
- pmemory_barrier, 0, NULL);
+ m_commandBuffer->PipelineBarrier(src_stages, dest_stages, 0, 0, NULL, 1, pmemory_barrier, 0, NULL);
// finish recording the command buffer
err = m_commandBuffer->EndCommandBuffer();
ASSERT_VK_SUCCESS(err);
}
-VkIndexBufferObj::VkIndexBufferObj(VkDeviceObj *device)
- : VkConstantBufferObj(device) {}
+VkIndexBufferObj::VkIndexBufferObj(VkDeviceObj *device) : VkConstantBufferObj(device) {}
-void VkIndexBufferObj::CreateAndInitBuffer(int numIndexes,
- VkIndexType indexType,
- const void *data) {
+void VkIndexBufferObj::CreateAndInitBuffer(int numIndexes, VkIndexType indexType, const void *data) {
m_numVertices = numIndexes;
m_indexType = indexType;
switch (indexType) {
}
const size_t allocationSize = numIndexes * m_stride;
- VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
- VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
+ VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
init_as_src_and_dst(*m_device, allocationSize, reqs);
void *pData = memory().map();
this->m_descriptorBufferInfo.range = allocationSize;
}
-void VkIndexBufferObj::Bind(VkCommandBuffer commandBuffer,
- VkDeviceSize offset) {
+void VkIndexBufferObj::Bind(VkCommandBuffer commandBuffer, VkDeviceSize offset) {
vkCmdBindIndexBuffer(commandBuffer, handle(), offset, m_indexType);
}
return stageInfo;
}
-VkShaderObj::VkShaderObj(VkDeviceObj *device, const char *shader_code,
- VkShaderStageFlagBits stage,
- VkRenderFramework *framework,
+VkShaderObj::VkShaderObj(VkDeviceObj *device, const char *shader_code, VkShaderStageFlagBits stage, VkRenderFramework *framework,
char const *name) {
VkResult U_ASSERT_ONLY err = VK_SUCCESS;
std::vector<unsigned int> spv;
((uint32_t *)moduleCreateInfo.pCode)[0] = ICD_SPV_MAGIC;
((uint32_t *)moduleCreateInfo.pCode)[1] = 0;
((uint32_t *)moduleCreateInfo.pCode)[2] = stage;
- memcpy(((uint32_t *)moduleCreateInfo.pCode + 3), shader_code,
- shader_len + 1);
+ memcpy(((uint32_t *)moduleCreateInfo.pCode + 3), shader_code, shader_len + 1);
} else {
m_vertexBufferCount = 0;
- m_ia_state.sType =
- VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
+ m_ia_state.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
m_ia_state.pNext = VK_NULL_HANDLE;
m_ia_state.flags = 0;
m_ia_state.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
m_ia_state.primitiveRestartEnable = VK_FALSE;
- m_rs_state.sType =
- VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
+ m_rs_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
m_rs_state.pNext = VK_NULL_HANDLE;
m_rs_state.flags = 0;
m_rs_state.depthClampEnable = VK_TRUE;
m_vp_state.pViewports = NULL;
m_vp_state.pScissors = NULL;
- m_ds_state.sType =
- VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
+ m_ds_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
m_ds_state.pNext = VK_NULL_HANDLE, m_ds_state.depthTestEnable = VK_FALSE;
m_ds_state.flags = 0;
m_ds_state.depthWriteEnable = VK_FALSE;
m_ds_state.front = m_ds_state.back;
};
-void VkPipelineObj::AddShader(VkShaderObj *shader) {
- m_shaderObjs.push_back(shader);
-}
+void VkPipelineObj::AddShader(VkShaderObj *shader) { m_shaderObjs.push_back(shader); }
-void VkPipelineObj::AddVertexInputAttribs(
- VkVertexInputAttributeDescription *vi_attrib, uint32_t count) {
+void VkPipelineObj::AddVertexInputAttribs(VkVertexInputAttributeDescription *vi_attrib, uint32_t count) {
m_vi_state.pVertexAttributeDescriptions = vi_attrib;
m_vi_state.vertexAttributeDescriptionCount = count;
}
-void VkPipelineObj::AddVertexInputBindings(VkVertexInputBindingDescription *vi_binding,
- uint32_t count) {
+void VkPipelineObj::AddVertexInputBindings(VkVertexInputBindingDescription *vi_binding, uint32_t count) {
m_vi_state.pVertexBindingDescriptions = vi_binding;
m_vi_state.vertexBindingDescriptionCount = count;
}
-void VkPipelineObj::AddColorAttachment(
- uint32_t binding, const VkPipelineColorBlendAttachmentState *att) {
+void VkPipelineObj::AddColorAttachment(uint32_t binding, const VkPipelineColorBlendAttachmentState *att) {
if (binding + 1 > m_colorAttachments.size()) {
m_colorAttachments.resize(binding + 1);
}
m_colorAttachments[binding] = *att;
}
-void VkPipelineObj::SetDepthStencil(
- const VkPipelineDepthStencilStateCreateInfo *ds_state) {
+void VkPipelineObj::SetDepthStencil(const VkPipelineDepthStencilStateCreateInfo *ds_state) {
m_ds_state.depthTestEnable = ds_state->depthTestEnable;
m_ds_state.depthWriteEnable = ds_state->depthWriteEnable;
m_ds_state.depthBoundsTestEnable = ds_state->depthBoundsTestEnable;
void VkPipelineObj::MakeDynamic(VkDynamicState state) {
/* Only add a state once */
- for (auto it = m_dynamic_state_enables.begin();
- it != m_dynamic_state_enables.end(); it++) {
+ for (auto it = m_dynamic_state_enables.begin(); it != m_dynamic_state_enables.end(); it++) {
if ((*it) == state)
return;
}
m_dynamic_state_enables.push_back(state);
}
-void VkPipelineObj::SetMSAA(
- const VkPipelineMultisampleStateCreateInfo *ms_state) {
- m_ms_state = *ms_state;
-}
-
-void VkPipelineObj::SetInputAssembly(
- const VkPipelineInputAssemblyStateCreateInfo *ia_state) {
- m_ia_state = *ia_state;
-}
+void VkPipelineObj::SetMSAA(const VkPipelineMultisampleStateCreateInfo *ms_state) { m_ms_state = *ms_state; }
-void VkPipelineObj::SetRasterization(
- const VkPipelineRasterizationStateCreateInfo *rs_state) {
- m_rs_state = *rs_state;
-}
+void VkPipelineObj::SetInputAssembly(const VkPipelineInputAssemblyStateCreateInfo *ia_state) { m_ia_state = *ia_state; }
-void VkPipelineObj::SetTessellation(
- const VkPipelineTessellationStateCreateInfo *te_state) {
- m_te_state = *te_state;
-}
+void VkPipelineObj::SetRasterization(const VkPipelineRasterizationStateCreateInfo *rs_state) { m_rs_state = *rs_state; }
+void VkPipelineObj::SetTessellation(const VkPipelineTessellationStateCreateInfo *te_state) { m_te_state = *te_state; }
-VkResult VkPipelineObj::CreateVKPipeline(VkPipelineLayout layout,
- VkRenderPass render_pass) {
+VkResult VkPipelineObj::CreateVKPipeline(VkPipelineLayout layout, VkRenderPass render_pass) {
VkGraphicsPipelineCreateInfo info = {};
VkPipelineDynamicStateCreateInfo dsci = {};
info.pStages = new VkPipelineShaderStageCreateInfo[info.stageCount];
for (size_t i = 0; i < m_shaderObjs.size(); i++) {
- ((VkPipelineShaderStageCreateInfo *)info.pStages)[i] =
- m_shaderObjs[i]->GetStageCreateInfo();
+ ((VkPipelineShaderStageCreateInfo *)info.pStages)[i] = m_shaderObjs[i]->GetStageCreateInfo();
}
m_vi_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
if (m_ia_state.topology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST) {
m_te_state.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
info.pTessellationState = &m_te_state;
- }
- else {
+ } else {
info.pTessellationState = nullptr;
}
return init_try(*m_device, info);
}
-VkCommandBufferObj::VkCommandBufferObj(VkDeviceObj *device,
- VkCommandPool pool) {
+VkCommandBufferObj::VkCommandBufferObj(VkDeviceObj *device, VkCommandPool pool) {
m_device = device;
init(*device, vk_testing::CommandBuffer::create_info(pool));
VkCommandBuffer VkCommandBufferObj::GetBufferHandle() { return handle(); }
-VkResult
-VkCommandBufferObj::BeginCommandBuffer(VkCommandBufferBeginInfo *pInfo) {
+VkResult VkCommandBufferObj::BeginCommandBuffer(VkCommandBufferBeginInfo *pInfo) {
begin(pInfo);
return VK_SUCCESS;
}
return VK_SUCCESS;
}
-void VkCommandBufferObj::PipelineBarrier(
- VkPipelineStageFlags src_stages, VkPipelineStageFlags dest_stages,
- VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount,
- const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount,
- const VkBufferMemoryBarrier *pBufferMemoryBarriers,
- uint32_t imageMemoryBarrierCount,
- const VkImageMemoryBarrier *pImageMemoryBarriers) {
- vkCmdPipelineBarrier(handle(), src_stages, dest_stages, dependencyFlags,
- memoryBarrierCount, pMemoryBarriers,
- bufferMemoryBarrierCount, pBufferMemoryBarriers,
- imageMemoryBarrierCount, pImageMemoryBarriers);
+void VkCommandBufferObj::PipelineBarrier(VkPipelineStageFlags src_stages, VkPipelineStageFlags dest_stages,
+ VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount,
+ const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount,
+ const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount,
+ const VkImageMemoryBarrier *pImageMemoryBarriers) {
+ vkCmdPipelineBarrier(handle(), src_stages, dest_stages, dependencyFlags, memoryBarrierCount, pMemoryBarriers,
+ bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
}
-void VkCommandBufferObj::ClearAllBuffers(VkClearColorValue clear_color,
- float depth_clear_color,
- uint32_t stencil_clear_color,
+void VkCommandBufferObj::ClearAllBuffers(VkClearColorValue clear_color, float depth_clear_color, uint32_t stencil_clear_color,
VkDepthStencilObj *depthStencilObj) {
uint32_t i;
- const VkFlags output_mask = VK_ACCESS_HOST_WRITE_BIT |
- VK_ACCESS_SHADER_WRITE_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_TRANSFER_WRITE_BIT;
+ const VkFlags output_mask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
const VkFlags input_mask = 0;
// whatever we want to do, we do it to the whole buffer
for (i = 0; i < m_renderTargets.size(); i++) {
memory_barrier.image = m_renderTargets[i]->image();
memory_barrier.oldLayout = m_renderTargets[i]->layout();
- vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0,
- NULL, 1, pmemory_barrier);
+ vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0, NULL, 1, pmemory_barrier);
m_renderTargets[i]->layout(memory_barrier.newLayout);
- vkCmdClearColorImage(handle(), m_renderTargets[i]->image(),
- VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1,
- &srRange);
+ vkCmdClearColorImage(handle(), m_renderTargets[i]->image(), VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &srRange);
}
if (depthStencilObj) {
memory_barrier.image = depthStencilObj->handle();
memory_barrier.subresourceRange = dsRange;
- vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0,
- NULL, 1, pmemory_barrier);
+ vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0, NULL, 1, pmemory_barrier);
- VkClearDepthStencilValue clear_value = {depth_clear_color,
- stencil_clear_color};
- vkCmdClearDepthStencilImage(handle(), depthStencilObj->handle(),
- VK_IMAGE_LAYOUT_GENERAL, &clear_value, 1,
- &dsRange);
+ VkClearDepthStencilValue clear_value = {depth_clear_color, stencil_clear_color};
+ vkCmdClearDepthStencilImage(handle(), depthStencilObj->handle(), VK_IMAGE_LAYOUT_GENERAL, &clear_value, 1, &dsRange);
// prepare depth buffer for rendering
memory_barrier.image = depthStencilObj->handle();
memory_barrier.newLayout = memory_barrier.oldLayout;
memory_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
memory_barrier.subresourceRange = dsRange;
- vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0,
- NULL, 1, pmemory_barrier);
+ vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0, NULL, 1, pmemory_barrier);
}
}
-void VkCommandBufferObj::FillBuffer(VkBuffer buffer, VkDeviceSize offset,
- VkDeviceSize fill_size, uint32_t data) {
+void VkCommandBufferObj::FillBuffer(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize fill_size, uint32_t data) {
vkCmdFillBuffer(handle(), buffer, offset, fill_size, data);
}
-void VkCommandBufferObj::UpdateBuffer(VkBuffer buffer, VkDeviceSize dstOffset,
- VkDeviceSize dataSize,
- const void *pData) {
+void VkCommandBufferObj::UpdateBuffer(VkBuffer buffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void *pData) {
vkCmdUpdateBuffer(handle(), buffer, dstOffset, dataSize, pData);
}
-void VkCommandBufferObj::CopyImage(VkImage srcImage,
- VkImageLayout srcImageLayout,
- VkImage dstImage,
- VkImageLayout dstImageLayout,
- uint32_t regionCount,
- const VkImageCopy *pRegions) {
- vkCmdCopyImage(handle(), srcImage, srcImageLayout, dstImage, dstImageLayout,
- regionCount, pRegions);
+void VkCommandBufferObj::CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout,
+ uint32_t regionCount, const VkImageCopy *pRegions) {
+ vkCmdCopyImage(handle(), srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
}
-void VkCommandBufferObj::ResolveImage(VkImage srcImage,
- VkImageLayout srcImageLayout,
- VkImage dstImage,
- VkImageLayout dstImageLayout,
- uint32_t regionCount,
- const VkImageResolve *pRegions) {
- vkCmdResolveImage(handle(), srcImage, srcImageLayout, dstImage,
- dstImageLayout, regionCount, pRegions);
+void VkCommandBufferObj::ResolveImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage,
+ VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve *pRegions) {
+ vkCmdResolveImage(handle(), srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
}
void VkCommandBufferObj::PrepareAttachments() {
uint32_t i;
- const VkFlags output_mask = VK_ACCESS_HOST_WRITE_BIT |
- VK_ACCESS_SHADER_WRITE_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_TRANSFER_WRITE_BIT;
- const VkFlags input_mask =
- VK_ACCESS_HOST_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT |
- VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT |
- VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_MEMORY_READ_BIT;
+ const VkFlags output_mask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
+ const VkFlags input_mask = VK_ACCESS_HOST_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_INDEX_READ_BIT |
+ VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT |
+ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
+ VK_ACCESS_MEMORY_READ_BIT;
VkImageSubresourceRange srRange = {};
srRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
for (i = 0; i < m_renderTargets.size(); i++) {
memory_barrier.image = m_renderTargets[i]->image();
memory_barrier.oldLayout = m_renderTargets[i]->layout();
- vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0,
- NULL, 1, pmemory_barrier);
+ vkCmdPipelineBarrier(handle(), src_stages, dest_stages, 0, 0, NULL, 0, NULL, 1, pmemory_barrier);
m_renderTargets[i]->layout(memory_barrier.newLayout);
}
}
void VkCommandBufferObj::EndRenderPass() { vkCmdEndRenderPass(handle()); }
-void VkCommandBufferObj::SetViewport(uint32_t firstViewport,
- uint32_t viewportCount,
- const VkViewport *pViewports) {
+void VkCommandBufferObj::SetViewport(uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports) {
vkCmdSetViewport(handle(), firstViewport, viewportCount, pViewports);
}
-void VkCommandBufferObj::SetScissor(uint32_t firstScissor,
- uint32_t scissorCount,
- const VkRect2D *pScissors) {
+void VkCommandBufferObj::SetScissor(uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors) {
vkCmdSetScissor(handle(), firstScissor, scissorCount, pScissors);
}
-void VkCommandBufferObj::SetLineWidth(float lineWidth) {
- vkCmdSetLineWidth(handle(), lineWidth);
-}
+void VkCommandBufferObj::SetLineWidth(float lineWidth) { vkCmdSetLineWidth(handle(), lineWidth); }
-void VkCommandBufferObj::SetDepthBias(float depthBiasConstantFactor,
- float depthBiasClamp,
- float depthBiasSlopeFactor) {
- vkCmdSetDepthBias(handle(), depthBiasConstantFactor, depthBiasClamp,
- depthBiasSlopeFactor);
+void VkCommandBufferObj::SetDepthBias(float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor) {
+ vkCmdSetDepthBias(handle(), depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
}
-void VkCommandBufferObj::SetBlendConstants(const float blendConstants[4]) {
- vkCmdSetBlendConstants(handle(), blendConstants);
-}
+void VkCommandBufferObj::SetBlendConstants(const float blendConstants[4]) { vkCmdSetBlendConstants(handle(), blendConstants); }
-void VkCommandBufferObj::SetDepthBounds(float minDepthBounds,
- float maxDepthBounds) {
+void VkCommandBufferObj::SetDepthBounds(float minDepthBounds, float maxDepthBounds) {
vkCmdSetDepthBounds(handle(), minDepthBounds, maxDepthBounds);
}
-void VkCommandBufferObj::SetStencilReadMask(VkStencilFaceFlags faceMask,
- uint32_t compareMask) {
+void VkCommandBufferObj::SetStencilReadMask(VkStencilFaceFlags faceMask, uint32_t compareMask) {
vkCmdSetStencilCompareMask(handle(), faceMask, compareMask);
}
-void VkCommandBufferObj::SetStencilWriteMask(VkStencilFaceFlags faceMask,
- uint32_t writeMask) {
+void VkCommandBufferObj::SetStencilWriteMask(VkStencilFaceFlags faceMask, uint32_t writeMask) {
vkCmdSetStencilWriteMask(handle(), faceMask, writeMask);
}
-void VkCommandBufferObj::SetStencilReference(VkStencilFaceFlags faceMask,
- uint32_t reference) {
+void VkCommandBufferObj::SetStencilReference(VkStencilFaceFlags faceMask, uint32_t reference) {
vkCmdSetStencilReference(handle(), faceMask, reference);
}
-void VkCommandBufferObj::AddRenderTarget(VkImageObj *renderTarget) {
- m_renderTargets.push_back(renderTarget);
-}
+void VkCommandBufferObj::AddRenderTarget(VkImageObj *renderTarget) { m_renderTargets.push_back(renderTarget); }
-void VkCommandBufferObj::DrawIndexed(uint32_t indexCount,
- uint32_t instanceCount,
- uint32_t firstIndex, int32_t vertexOffset,
+void VkCommandBufferObj::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset,
uint32_t firstInstance) {
- vkCmdDrawIndexed(handle(), indexCount, instanceCount, firstIndex,
- vertexOffset, firstInstance);
+ vkCmdDrawIndexed(handle(), indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
-void VkCommandBufferObj::Draw(uint32_t vertexCount, uint32_t instanceCount,
- uint32_t firstVertex, uint32_t firstInstance) {
+void VkCommandBufferObj::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) {
vkCmdDraw(handle(), vertexCount, instanceCount, firstVertex, firstInstance);
}
}
void VkCommandBufferObj::BindPipeline(VkPipelineObj &pipeline) {
- vkCmdBindPipeline(handle(), VK_PIPELINE_BIND_POINT_GRAPHICS,
- pipeline.handle());
+ vkCmdBindPipeline(handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.handle());
}
void VkCommandBufferObj::BindDescriptorSet(VkDescriptorSetObj &descriptorSet) {
// bind pipeline, vertex buffer (descriptor set) and WVP (dynamic buffer
// view)
- vkCmdBindDescriptorSets(handle(), VK_PIPELINE_BIND_POINT_GRAPHICS,
- descriptorSet.GetPipelineLayout(), 0, 1, &set_obj,
- 0, NULL);
+ vkCmdBindDescriptorSets(handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, descriptorSet.GetPipelineLayout(), 0, 1, &set_obj, 0, NULL);
}
-void VkCommandBufferObj::BindIndexBuffer(VkIndexBufferObj *indexBuffer,
- VkDeviceSize offset) {
- vkCmdBindIndexBuffer(handle(), indexBuffer->handle(), offset,
- indexBuffer->GetIndexType());
+void VkCommandBufferObj::BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) {
+ vkCmdBindIndexBuffer(handle(), indexBuffer->handle(), offset, indexBuffer->GetIndexType());
}
-void VkCommandBufferObj::BindVertexBuffer(VkConstantBufferObj *vertexBuffer,
- VkDeviceSize offset,
- uint32_t binding) {
- vkCmdBindVertexBuffers(handle(), binding, 1, &vertexBuffer->handle(),
- &offset);
+void VkCommandBufferObj::BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) {
+ vkCmdBindVertexBuffers(handle(), binding, 1, &vertexBuffer->handle(), &offset);
}
bool VkDepthStencilObj::Initialized() { return m_initialized; }
-VkDepthStencilObj::VkDepthStencilObj(VkDeviceObj *device) : VkImageObj(device) {m_initialized = false;}
+VkDepthStencilObj::VkDepthStencilObj(VkDeviceObj *device) : VkImageObj(device) { m_initialized = false; }
VkImageView *VkDepthStencilObj::BindInfo() { return &m_attachmentBindInfo; }
-void VkDepthStencilObj::Init(VkDeviceObj *device, int32_t width, int32_t height,
- VkFormat format, VkImageUsageFlags usage) {
+void VkDepthStencilObj::Init(VkDeviceObj *device, int32_t width, int32_t height, VkFormat format, VkImageUsageFlags usage) {
VkImageViewCreateInfo view_info = {};
m_depth_stencil_fmt = format;
/* create image */
- init(width, height, m_depth_stencil_fmt,
- usage,
- VK_IMAGE_TILING_OPTIMAL);
+ init(width, height, m_depth_stencil_fmt, usage, VK_IMAGE_TILING_OPTIMAL);
VkImageAspectFlags aspect = VK_IMAGE_ASPECT_DEPTH_BIT;
if (vk_format_is_depth_and_stencil(format))
#include "vktestframework.h"
#endif
+#include <array>
#include <map>
#include <vector>
-#include <array>
using namespace std;
class VkDeviceObj : public vk_testing::Device {
public:
VkDeviceObj(uint32_t id, VkPhysicalDevice obj);
- VkDeviceObj(uint32_t id, VkPhysicalDevice obj,
- std::vector<const char *> &extension_names,
+ VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<const char *> &extension_names,
VkPhysicalDeviceFeatures *features = nullptr);
VkDevice device() { return handle(); }
void InitRenderTarget(VkImageView *dsBinding);
void InitRenderTarget(uint32_t targets, VkImageView *dsBinding);
void InitFramework();
- void InitFramework(std::vector<const char *> instance_layer_names,
- std::vector<const char *> instance_extension_names,
- std::vector<const char *> device_extension_names,
- PFN_vkDebugReportCallbackEXT = NULL,
+ void InitFramework(std::vector<const char *> instance_layer_names, std::vector<const char *> instance_extension_names,
+ std::vector<const char *> device_extension_names, PFN_vkDebugReportCallbackEXT = NULL,
void *userData = NULL);
void ShutdownFramework();
void InitState(VkPhysicalDeviceFeatures *features = nullptr);
- const VkRenderPassBeginInfo &renderPassBeginInfo() const {
- return m_renderPassBeginInfo;
- }
+ const VkRenderPassBeginInfo &renderPassBeginInfo() const { return m_renderPassBeginInfo; }
protected:
VkApplicationInfo app_info;
VkResult BeginCommandBuffer();
VkResult BeginCommandBuffer(VkCommandBufferBeginInfo *pInfo);
VkResult EndCommandBuffer();
- void PipelineBarrier(VkPipelineStageFlags src_stages,
- VkPipelineStageFlags dest_stages,
- VkDependencyFlags dependencyFlags,
- uint32_t memoryBarrierCount,
- const VkMemoryBarrier *pMemoryBarriers,
- uint32_t bufferMemoryBarrierCount,
- const VkBufferMemoryBarrier *pBufferMemoryBarriers,
- uint32_t imageMemoryBarrierCount,
+ void PipelineBarrier(VkPipelineStageFlags src_stages, VkPipelineStageFlags dest_stages, VkDependencyFlags dependencyFlags,
+ uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount,
+ const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount,
const VkImageMemoryBarrier *pImageMemoryBarriers);
void AddRenderTarget(VkImageObj *renderTarget);
void AddDepthStencil();
- void ClearAllBuffers(VkClearColorValue clear_color, float depth_clear_color,
- uint32_t stencil_clear_color,
+ void ClearAllBuffers(VkClearColorValue clear_color, float depth_clear_color, uint32_t stencil_clear_color,
VkDepthStencilObj *depthStencilObj);
void PrepareAttachments();
void BindPipeline(VkPipelineObj &pipeline);
void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
- void BindVertexBuffer(VkConstantBufferObj *vertexBuffer,
- VkDeviceSize offset, uint32_t binding);
+ void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset);
void BeginRenderPass(const VkRenderPassBeginInfo &info);
void EndRenderPass();
- void FillBuffer(VkBuffer buffer, VkDeviceSize offset,
- VkDeviceSize fill_size, uint32_t data);
- void Draw(uint32_t vertexCount, uint32_t instanceCount,
- uint32_t firstVertex, uint32_t firstInstance);
- void DrawIndexed(uint32_t indexCount, uint32_t instanceCount,
- uint32_t firstIndex, int32_t vertexOffset,
+ void FillBuffer(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize fill_size, uint32_t data);
+ void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance);
+ void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset,
uint32_t firstInstance);
void QueueCommandBuffer(bool checkSuccess = true);
void QueueCommandBuffer(VkFence fence, bool checkSuccess = true);
- void SetViewport(uint32_t firstViewport, uint32_t viewportCount,
- const VkViewport *pViewports);
- void SetScissor(uint32_t firstScissor, uint32_t scissorCount,
- const VkRect2D *pScissors);
+ void SetViewport(uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports);
+ void SetScissor(uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors);
void SetLineWidth(float lineWidth);
- void SetDepthBias(float depthBiasConstantFactor, float depthBiasClamp,
- float depthBiasSlopeFactor);
+ void SetDepthBias(float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor);
void SetBlendConstants(const float blendConstants[4]);
void SetDepthBounds(float minDepthBounds, float maxDepthBounds);
void SetStencilReadMask(VkStencilFaceFlags faceMask, uint32_t compareMask);
void SetStencilWriteMask(VkStencilFaceFlags faceMask, uint32_t writeMask);
void SetStencilReference(VkStencilFaceFlags faceMask, uint32_t reference);
- void UpdateBuffer(VkBuffer buffer, VkDeviceSize dstOffset,
- VkDeviceSize dataSize, const void *pData);
- void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout,
- VkImage dstImage, VkImageLayout dstImageLayout,
+ void UpdateBuffer(VkBuffer buffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void *pData);
+ void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout,
uint32_t regionCount, const VkImageCopy *pRegions);
- void ResolveImage(VkImage srcImage, VkImageLayout srcImageLayout,
- VkImage dstImage, VkImageLayout dstImageLayout,
+ void ResolveImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout,
uint32_t regionCount, const VkImageResolve *pRegions);
protected:
class VkConstantBufferObj : public vk_testing::Buffer {
public:
VkConstantBufferObj(VkDeviceObj *device,
- VkBufferUsageFlags usage =
- VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
- VK_BUFFER_USAGE_TRANSFER_DST_BIT);
- VkConstantBufferObj(VkDeviceObj *device, int constantCount,
- int constantSize, const void *data,
- VkBufferUsageFlags usage =
- VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
- VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ VkBufferUsageFlags usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
+ VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void *data,
+ VkBufferUsageFlags usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
~VkConstantBufferObj();
- void BufferMemoryBarrier(
- VkFlags srcAccessMask = VK_ACCESS_HOST_WRITE_BIT |
- VK_ACCESS_SHADER_WRITE_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_TRANSFER_WRITE_BIT,
- VkFlags dstAccessMask = VK_ACCESS_HOST_READ_BIT |
- VK_ACCESS_INDIRECT_COMMAND_READ_BIT |
- VK_ACCESS_INDEX_READ_BIT |
- VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT |
- VK_ACCESS_UNIFORM_READ_BIT |
- VK_ACCESS_SHADER_READ_BIT |
- VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
- VK_ACCESS_MEMORY_READ_BIT);
-
- void Bind(VkCommandBuffer commandBuffer, VkDeviceSize offset,
- uint32_t binding);
+ void BufferMemoryBarrier(VkFlags srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT |
+ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
+ VkFlags dstAccessMask = VK_ACCESS_HOST_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT |
+ VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT |
+ VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT |
+ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_MEMORY_READ_BIT);
+
+ void Bind(VkCommandBuffer commandBuffer, VkDeviceSize offset, uint32_t binding);
VkDescriptorBufferInfo m_descriptorBufferInfo;
class VkIndexBufferObj : public VkConstantBufferObj {
public:
VkIndexBufferObj(VkDeviceObj *device);
- void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat,
- const void *data);
+ void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void *data);
void Bind(VkCommandBuffer commandBuffer, VkDeviceSize offset);
VkIndexType GetIndexType();
public:
VkRenderpassObj(VkDeviceObj *device);
~VkRenderpassObj();
- VkRenderPass handle() {return m_renderpass;}
+ VkRenderPass handle() { return m_renderpass; }
protected:
VkRenderPass m_renderpass;
bool IsCompatible(VkFlags usage, VkFlags features);
public:
- void init(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage,
- VkImageTiling tiling = VK_IMAGE_TILING_LINEAR,
+ void init(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage, VkImageTiling tiling = VK_IMAGE_TILING_LINEAR,
VkMemoryPropertyFlags reqs = 0);
- void init_no_layout(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage,
- VkImageTiling tiling = VK_IMAGE_TILING_LINEAR,
- VkMemoryPropertyFlags reqs = 0);
+ void init_no_layout(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage, VkImageTiling tiling = VK_IMAGE_TILING_LINEAR,
+ VkMemoryPropertyFlags reqs = 0);
// void clear( CommandBuffer*, uint32_t[4] );
- void layout(VkImageLayout layout) {
- m_descriptorImageInfo.imageLayout = layout;
- }
+ void layout(VkImageLayout layout) { m_descriptorImageInfo.imageLayout = layout; }
VkDeviceMemory memory() const { return Image::memory().handle(); }
void UnmapMemory() { Image::memory().unmap(); }
- void ImageMemoryBarrier(VkCommandBufferObj *cmd, VkImageAspectFlags aspect,
- VkFlags output_mask, VkFlags input_mask,
+ void ImageMemoryBarrier(VkCommandBufferObj *cmd, VkImageAspectFlags aspect, VkFlags output_mask, VkFlags input_mask,
VkImageLayout image_layout);
VkResult CopyImage(VkImageObj &src_image);
createView.components.g = VK_COMPONENT_SWIZZLE_G;
createView.components.b = VK_COMPONENT_SWIZZLE_B;
createView.components.a = VK_COMPONENT_SWIZZLE_A;
- createView.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0,
- 1};
+ createView.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
createView.flags = 0;
m_targetView.init(*m_device, createView);
}
return m_targetView.handle();
}
- void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspectFlags aspect,
- VkImageLayout image_layout);
+ void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspectFlags aspect, VkImageLayout image_layout);
void SetLayout(VkImageAspectFlags aspect, VkImageLayout image_layout);
VkImageLayout layout() const { return m_descriptorImageInfo.imageLayout; }
class VkDepthStencilObj : public VkImageObj {
public:
VkDepthStencilObj(VkDeviceObj *device);
- void Init(VkDeviceObj *device, int32_t width, int32_t height,
- VkFormat format, VkImageUsageFlags usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
+ void Init(VkDeviceObj *device, int32_t width, int32_t height, VkFormat format,
+ VkImageUsageFlags usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
bool Initialized();
VkImageView *BindInfo();
~VkDescriptorSetObj();
int AppendDummy();
- int AppendBuffer(VkDescriptorType type,
- VkConstantBufferObj &constantBuffer);
+ int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
int AppendSamplerTexture(VkSamplerObj *sampler, VkTextureObj *texture);
void CreateVKDescriptorSet(VkCommandBufferObj *commandBuffer);
VkDescriptorSet GetDescriptorSetHandle() const;
VkPipelineLayout GetPipelineLayout() const;
- int GetTypeCounts() {return m_type_counts.size();}
+ int GetTypeCounts() { return m_type_counts.size(); }
protected:
VkDeviceObj *m_device;
class VkShaderObj : public vk_testing::ShaderModule {
public:
- VkShaderObj(VkDeviceObj *device, const char *shaderText,
- VkShaderStageFlagBits stage, VkRenderFramework *framework,
+ VkShaderObj(VkDeviceObj *device, const char *shaderText, VkShaderStageFlagBits stage, VkRenderFramework *framework,
char const *name = "main");
VkPipelineShaderStageCreateInfo GetStageCreateInfo() const;
public:
VkPipelineObj(VkDeviceObj *device);
void AddShader(VkShaderObj *shaderObj);
- void AddVertexInputAttribs(VkVertexInputAttributeDescription *vi_attrib,
- uint32_t count);
- void AddVertexInputBindings(VkVertexInputBindingDescription *vi_binding,
- uint32_t count);
- void AddColorAttachment(uint32_t binding,
- const VkPipelineColorBlendAttachmentState *att);
+ void AddVertexInputAttribs(VkVertexInputAttributeDescription *vi_attrib, uint32_t count);
+ void AddVertexInputBindings(VkVertexInputBindingDescription *vi_binding, uint32_t count);
+ void AddColorAttachment(uint32_t binding, const VkPipelineColorBlendAttachmentState *att);
void MakeDynamic(VkDynamicState state);
void AddColorAttachment() {
void SetTessellation(const VkPipelineTessellationStateCreateInfo *te_state);
void SetViewport(const vector<VkViewport> viewports);
void SetScissor(const vector<VkRect2D> scissors);
- VkResult CreateVKPipeline(VkPipelineLayout layout,
- VkRenderPass render_pass);
+ VkResult CreateVKPipeline(VkPipelineLayout layout, VkRenderPass render_pass);
protected:
VkPipelineVertexInputStateCreateInfo m_vi_state;