Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new example: using compileManager to change between programs #311

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

theodoregoetz
Copy link
Contributor

The example utils/vsgcompilemanager switches between two scenes, one that uses a storage buffer and another that does not. This switch happens every 60 frames. On the third time showing the scene with the storage buffer, VSG emits the following warning:

Warning: Context::reserve(const ResourceRequirements& requirements) 
invalid combination of required_maxSets (0) & required_descriptorPoolSizes (1) 
unable to allocate DescriptorPool.

… storage buffers

The example utils/vsgcompilemanager switches between two scenes, one that uses a storage buffer and another that does not. This switch happens every 60 frames. On the third record of the scene with the storage buffer, VSG emits the following warning: Warning: Context::reserve(const ResourceRequirements& requirements) invalid combination of required_maxSets (0) & required_descriptorPoolSizes (1) unable to allocate DescriptorPool.
@robertosfield
Copy link
Collaborator

@theodoregoetz is this example still useful?

@theodoregoetz
Copy link
Contributor Author

I just ran it with -d -v and now emits a new validation error:

VUID-RuntimeSpirv-NonWritable-06340(ERROR / SPEC): msgNum: 269944751 - Validation Error: [ VUID-RuntimeSpirv-NonWritable-06340 ] Object 0: handle = 0x5f000000005f, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x101707af | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[1] SPIR-V (VK_SHADER_STAGE_FRAGMENT_BIT) uses descriptor [Set 0, Binding 0, variable "CellColors"] (type VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) which is not marked with NonWritable, but fragmentStoresAndAtomics was not enabled. The Vulkan spec states: If fragmentStoresAndAtomics is not enabled, then all storage image, storage texel buffer, and storage buffer variables in the fragment stage must be decorated with the NonWritable decoration (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-RuntimeSpirv-NonWritable-06340)
    Objects: 1
        [0] 0x5f000000005f, type: 15, name: NULL

I think this can be fixed by adding "readonly" on the buffers in the shader code. But beyond that, it's still a valid test, if not exactly an example per-se. Do you have a better place for test programs?

@robertosfield
Copy link
Collaborator

We don't presently have test specific place, but perhaps we should have vsgExamples/tests directory alongside vsgExamples/examples?

@robertosfield
Copy link
Collaborator

I have merged the vsgcompilemanager test program into a branch and moved it into vsgExamples/tests. Running 'vsgcompilemanager -d' I see:

VUID-RuntimeSpirv-NonWritable-06340(ERROR / SPEC): msgNum: 269944751 - Validation Error: [ VUID-RuntimeSpirv-NonWritable-06340 ] Object 0: handle = 0x95a125000000001a, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x101707af | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[1] SPIR-V (VK_SHADER_STAGE_FRAGMENT_BIT) uses descriptor [Set 0, Binding 0, variable "CellColors"] (type VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) which is not marked with NonWritable, but fragmentStoresAndAtomics was not enabled. The Vulkan spec states: If fragmentStoresAndAtomics is not enabled, then all storage image, storage texel buffer, and storage buffer variables in the fragment stage must be decorated with the NonWritable decoration (https://vulkan.lunarg.com/doc/view/1.3.290.0/linux/1.3-extensions/vkspec.html#VUID-RuntimeSpirv-NonWritable-06340)
    Objects: 1
        [0] 0x95a125000000001a, type: 15, name: NULL
VUID-RuntimeSpirv-NonWritable-06340(ERROR / SPEC): msgNum: 269944751 - Validation Error: [ VUID-RuntimeSpirv-NonWritable-06340 ] Object 0: handle = 0x74ea280000000054, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x101707af | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[1] SPIR-V (VK_SHADER_STAGE_FRAGMENT_BIT) uses descriptor [Set 0, Binding 0, variable "CellColors"] (type VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) which is not marked with NonWritable, but fragmentStoresAndAtomics was not enabled. The Vulkan spec states: If fragmentStoresAndAtomics is not enabled, then all storage image, storage texel buffer, and storage buffer variables in the fragment stage must be decorated with the NonWritable decoration (https://vulkan.lunarg.com/doc/view/1.3.290.0/linux/1.3-extensions/vkspec.html#VUID-RuntimeSpirv-NonWritable-06340)
    Objects: 1
        [0] 0x74ea280000000054, type: 15, name: NULL

I have a look into the shaders it's using.

@robertosfield
Copy link
Collaborator

As you suspect, adding readonly fixed the validation error:

diff --git a/tests/vsgcompilemanager/vsgcompilemanager.cpp b/tests/vsgcompilemanager/vsgcompilemanager.cpp
index 4d8fc72f..7ff48a33 100644
--- a/tests/vsgcompilemanager/vsgcompilemanager.cpp
+++ b/tests/vsgcompilemanager/vsgcompilemanager.cpp
@@ -13,7 +13,7 @@ void main() { gl_Position = (projection * modelView) * vec4(vertex, 1.0); }
 
 std::string FRAG0{R"(
 #version 450
-layout(set = 0, binding = 0) buffer CellColors { vec4[] cellColors; };
+layout(set = 0, binding = 0) readonly buffer CellColors { vec4[] cellColors; };
 layout(location = 0) out vec4 color;
 void main() { color = cellColors[gl_PrimitiveID]; }
 )"};

@robertosfield robertosfield merged commit 3c371b3 into vsg-dev:master Oct 18, 2024
@robertosfield
Copy link
Collaborator

I have now merged this test program with vsgExamples master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants