Adds specialization constant to computeheadless
This commit is contained in:
parent
685d2849da
commit
20668189f1
3 changed files with 12 additions and 2 deletions
|
|
@ -328,6 +328,15 @@ public:
|
||||||
// Create pipeline
|
// Create pipeline
|
||||||
VkComputePipelineCreateInfo computePipelineCreateInfo = vks::initializers::computePipelineCreateInfo(pipelineLayout, 0);
|
VkComputePipelineCreateInfo computePipelineCreateInfo = vks::initializers::computePipelineCreateInfo(pipelineLayout, 0);
|
||||||
|
|
||||||
|
// Create specialization constant holding struct
|
||||||
|
struct SpecializationHolding
|
||||||
|
{
|
||||||
|
uint32_t BUFFER_ELEMENT_COUNT = BUFFER_ELEMENTS;
|
||||||
|
} specialization;
|
||||||
|
// create a specialization map entry
|
||||||
|
VkSpecializationMapEntry specializationMapEntry = vks::initializers::specializationMapEntry(0, 0, sizeof(uint32_t));
|
||||||
|
VkSpecializationInfo specializationInfo = vks::initializers::specializationInfo(1, &specializationMapEntry, sizeof(SpecializationHolding), &specialization);
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo shaderStage = {};
|
VkPipelineShaderStageCreateInfo shaderStage = {};
|
||||||
shaderStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
shaderStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
shaderStage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
|
shaderStage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
|
||||||
|
|
@ -337,6 +346,8 @@ public:
|
||||||
shaderStage.module = vks::tools::loadShader(ASSET_PATH "shaders/computeheadless/headless.comp.spv", device);
|
shaderStage.module = vks::tools::loadShader(ASSET_PATH "shaders/computeheadless/headless.comp.spv", device);
|
||||||
#endif
|
#endif
|
||||||
shaderStage.pName = "main";
|
shaderStage.pName = "main";
|
||||||
|
shaderStage.pSpecializationInfo = &specializationInfo;
|
||||||
|
|
||||||
assert(shaderStage.module != VK_NULL_HANDLE);
|
assert(shaderStage.module != VK_NULL_HANDLE);
|
||||||
computePipelineCreateInfo.stage = shaderStage;
|
computePipelineCreateInfo.stage = shaderStage;
|
||||||
VK_CHECK_RESULT(vkCreateComputePipelines(device, pipelineCache, 1, &computePipelineCreateInfo, nullptr, &pipeline));
|
VK_CHECK_RESULT(vkCreateComputePipelines(device, pipelineCache, 1, &computePipelineCreateInfo, nullptr, &pipeline));
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ layout(binding = 0) buffer Pos {
|
||||||
|
|
||||||
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
|
||||||
// todo: pass via specialization constant
|
layout(constant_id = 0) const uint BUFFER_ELEMENTS = 32;
|
||||||
#define BUFFER_ELEMENTS 32
|
|
||||||
|
|
||||||
uint fibonacci(uint n) {
|
uint fibonacci(uint n) {
|
||||||
if(n <= 1){
|
if(n <= 1){
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue