Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
per-mathisen-arm committed Dec 2, 2024
1 parent e76a327 commit 5324e4e
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 10 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,10 @@ layer_test(thread_2 thread_2)
layer_test(thread_3 thread_3)
layer_test(compute_bda_sc compute_bda_sc)
layer_test(compute_bda_pushconstant compute_bda_pushconstant)
layer_test(compute_bda_ubo compute_bda_ubo)
layer_test(compute_bda_ubo_ssbo compute_bda_ubo --ssbo)
layer_test(compute_bda_ubo_fb compute_bda_ubo --frame-boundary)
# These three tests crash on Nvidia and freeze the GPU
#layer_test(compute_bda_ubo compute_bda_ubo)
#layer_test(compute_bda_ubo_ssbo compute_bda_ubo --ssbo)
#layer_test(compute_bda_ubo_fb compute_bda_ubo --frame-boundary)
add_test(NAME layer_test_thread_3_replay_blackhole_stress_1 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lava-replay -V -B vulkan_thread_3.vk)
set_tests_properties(layer_test_thread_3_replay_blackhole_stress_1 PROPERTIES FIXTURES_REQUIRED thread_3)
add_test(NAME layer_test_thread_3_replay_blackhole_stress_2 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/lava-replay -D -B vulkan_thread_3.vk)
Expand Down Expand Up @@ -552,6 +553,6 @@ layer_test(compute_2_2 compute_2 -j 1 -s 2)
layer_test(compute_3 compute_3)
layer_test(feature_1 feature_1)
layer_test(tool_1 tool_1)
layer_test(as_1 as_1)
#layer_test(multidevice_1 multidevice_1) # assert failure on memory type
#layer_test(as_1)
#layer_test(mesh_1)
75 changes: 75 additions & 0 deletions include/feature_detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ struct feature_detection
void check_VkPipelineColorBlendStateCreateInfo(const VkPipelineColorBlendStateCreateInfo* info)
{
if (info->logicOpEnable == VK_TRUE) core10.logicOp = true;

if (info->attachmentCount > 1)
{
for (uint32_t i = 1; i < info->attachmentCount; i++)
{
if (info->pAttachments[i].blendEnable != info->pAttachments[i - 1].blendEnable ||
info->pAttachments[i].srcColorBlendFactor != info->pAttachments[i - 1].srcColorBlendFactor ||
info->pAttachments[i].dstColorBlendFactor != info->pAttachments[i - 1].dstColorBlendFactor ||
info->pAttachments[i].colorBlendOp != info->pAttachments[i - 1].colorBlendOp ||
info->pAttachments[i].srcAlphaBlendFactor != info->pAttachments[i - 1].srcAlphaBlendFactor ||
info->pAttachments[i].dstAlphaBlendFactor != info->pAttachments[i - 1].dstAlphaBlendFactor ||
info->pAttachments[i].alphaBlendOp != info->pAttachments[i - 1].alphaBlendOp ||
info->pAttachments[i].colorWriteMask != info->pAttachments[i - 1].colorWriteMask)
{
core10.independentBlend = true;
}
}
}
}

void check_VkPipelineMultisampleStateCreateInfo(const VkPipelineMultisampleStateCreateInfo* info)
Expand Down Expand Up @@ -294,6 +312,35 @@ struct feature_detection
if (info->depthBoundsTestEnable == VK_TRUE) core10.depthBounds = true;
}

void check_VkImageViewCreateInfo(const VkImageViewCreateInfo* info)
{
if (info->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) core10.imageCubeArray = true;
}

void check_VkCommandBufferInheritanceInfo(const VkCommandBufferInheritanceInfo* info)
{
if (info->occlusionQueryEnable != VK_FALSE || ((info->queryFlags & ~(VK_QUERY_CONTROL_PRECISE_BIT)) == 0))
{
core10.inheritedQueries = true;
}
}

void check_VkPipelineViewportStateCreateInfo(const VkPipelineViewportStateCreateInfo* info)
{
if (info->viewportCount > 1 || info->scissorCount > 1)
{
core10.multiViewport = true;
}
}

void check_VkPipelineViewportExclusiveScissorStateCreateInfoNV(const VkPipelineViewportExclusiveScissorStateCreateInfoNV* info)
{
if (info->exclusiveScissorCount != 0 && info->exclusiveScissorCount != 1)
{
core10.multiViewport = true;
}
}

// --- Checking functions. Call these for all these Vulkan commands after they are successfully called, before returning. ---

void check_vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
Expand Down Expand Up @@ -331,6 +378,30 @@ struct feature_detection
core13.dynamicRendering = true;
}

void check_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports)
{
if (firstViewport != 0 || viewportCount != 1)
{
core10.multiViewport = true;
}
}

void check_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors)
{
if (firstScissor != 0 || scissorCount != 1)
{
core10.multiViewport = true;
}
}

void check_vkCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors)
{
if (firstExclusiveScissor != 0 || exclusiveScissorCount != 1)
{
core10.multiViewport = true;
}
}

// --- Remove unused feature bits from these structures ---

void adjust_device_extensions(std::unordered_set<std::string>& exts)
Expand Down Expand Up @@ -370,6 +441,10 @@ struct feature_detection
CHECK_FEATURE10(sparseResidency8Samples);
CHECK_FEATURE10(sparseResidency16Samples);
CHECK_FEATURE10(sparseResidencyAliased);
CHECK_FEATURE10(independentBlend);
CHECK_FEATURE10(inheritedQueries);
CHECK_FEATURE10(multiViewport);
CHECK_FEATURE10(imageCubeArray);
#undef CHECK_FEATURE10
}

Expand Down
6 changes: 2 additions & 4 deletions src/suballocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,13 @@ suballoc_location suballoc_add_image(uint16_t tid, VkDevice device, VkImage imag
return r;
}

void suballoc_virtualswap_images(VkDevice device, const std::vector<VkImage>& images)
void suballoc_virtualswap_images(VkDevice device, const std::vector<VkImage>& images, VkMemoryPropertyFlags flags)
{
assert(run);
VkMemoryRequirements2 req = {};
const bool dedicated = fill_image_memreq(device, images.at(0), req, 0);
VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
const uint32_t memoryTypeIndex = get_device_memory_type(req.memoryRequirements.memoryTypeBits, flags);
VkMemoryAllocateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
VkMemoryAllocateInfo info = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, nullptr };
VkDeviceSize image_size = aligned_size(req.memoryRequirements.size, req.memoryRequirements.alignment);
info.memoryTypeIndex = memoryTypeIndex;
VkDeviceMemory mem = VK_NULL_HANDLE;
Expand Down
2 changes: 1 addition & 1 deletion src/suballocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ suballoc_location suballoc_find_buffer_memory(uint32_t buffer_index);
int suballoc_internal_test();

/// Special handling of virtual swapchain images
void suballoc_virtualswap_images(VkDevice device, const std::vector<VkImage>& images);
void suballoc_virtualswap_images(VkDevice device, const std::vector<VkImage>& images, VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
6 changes: 5 additions & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,11 @@ bool shader_has_buffer_devices_addresses(const uint32_t* code, uint32_t code_siz
do {
opcode = uint16_t(insn[0]);
word_count = uint16_t(insn[0] >> 16);
if (opcode == SpvOpExtension && strcmp((char*)&insn[2], "KHR_physical_storage_buffer") == 0) return true;
if (opcode == SpvOpExtension)
{
if (strcmp((char*)&insn[2], "KHR_physical_storage_buffer") == 0) return true;
else if (strcmp((char*)&insn[2], "EXT_physical_storage_buffer") == 0) return true;
}
insn += word_count;
}
while (insn != code + code_size && opcode != SpvOpMemoryModel);
Expand Down

0 comments on commit 5324e4e

Please sign in to comment.