Make use of the new Flags iterator
This commit is contained in:
parent
401bfa3324
commit
de88873c35
|
|
@ -215,12 +215,8 @@ namespace Nz
|
|||
inline VkAccessFlags ToVulkan(MemoryAccessFlags memoryAccessFlags)
|
||||
{
|
||||
VkShaderStageFlags accessBits = 0;
|
||||
for (int i = 0; i <= UnderlyingCast(MemoryAccess::Max); ++i)
|
||||
{
|
||||
MemoryAccess memoryAccess = static_cast<MemoryAccess>(i);
|
||||
if (memoryAccessFlags.Test(memoryAccess))
|
||||
accessBits |= ToVulkan(memoryAccess);
|
||||
}
|
||||
for (MemoryAccess memoryAccess : memoryAccessFlags)
|
||||
accessBits |= ToVulkan(memoryAccess);
|
||||
|
||||
return accessBits;
|
||||
}
|
||||
|
|
@ -253,12 +249,8 @@ namespace Nz
|
|||
inline VkPipelineStageFlags ToVulkan(PipelineStageFlags pipelineStages)
|
||||
{
|
||||
VkShaderStageFlags pipelineStageBits = 0;
|
||||
for (int i = 0; i <= UnderlyingCast(PipelineStage::Max); ++i)
|
||||
{
|
||||
PipelineStage pipelineStage = static_cast<PipelineStage>(i);
|
||||
if (pipelineStages.Test(pipelineStage))
|
||||
pipelineStageBits |= ToVulkan(pipelineStage);
|
||||
}
|
||||
for (PipelineStage pipelineStage : pipelineStages)
|
||||
pipelineStageBits |= ToVulkan(pipelineStage);
|
||||
|
||||
return pipelineStageBits;
|
||||
}
|
||||
|
|
@ -415,12 +407,8 @@ namespace Nz
|
|||
inline VkShaderStageFlags ToVulkan(nzsl::ShaderStageTypeFlags stageType)
|
||||
{
|
||||
VkShaderStageFlags shaderStageBits = 0;
|
||||
for (int i = 0; i <= UnderlyingCast(nzsl::ShaderStageType::Max); ++i)
|
||||
{
|
||||
nzsl::ShaderStageType shaderStage = static_cast<nzsl::ShaderStageType>(i);
|
||||
if (stageType.Test(shaderStage))
|
||||
shaderStageBits |= ToVulkan(shaderStage);
|
||||
}
|
||||
for (nzsl::ShaderStageType shaderStage : stageType)
|
||||
shaderStageBits |= ToVulkan(shaderStage);
|
||||
|
||||
return shaderStageBits;
|
||||
}
|
||||
|
|
@ -482,12 +470,8 @@ namespace Nz
|
|||
inline VkImageUsageFlags ToVulkan(TextureUsageFlags textureLayout)
|
||||
{
|
||||
VkImageUsageFlags imageUsageBits = 0;
|
||||
for (int i = 0; i <= UnderlyingCast(TextureUsage::Max); ++i)
|
||||
{
|
||||
TextureUsage textureUsage = static_cast<TextureUsage>(i);
|
||||
if (textureLayout.Test(textureUsage))
|
||||
imageUsageBits |= ToVulkan(textureUsage);
|
||||
}
|
||||
for (TextureUsage textureUsage : textureLayout)
|
||||
imageUsageBits |= ToVulkan(textureUsage);
|
||||
|
||||
return imageUsageBits;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,18 +29,14 @@ namespace Nz
|
|||
{
|
||||
case ShaderLanguage::GLSL:
|
||||
{
|
||||
for (std::size_t i = 0; i < nzsl::ShaderStageTypeCount; ++i)
|
||||
for (nzsl::ShaderStageType shaderStage : shaderStages)
|
||||
{
|
||||
nzsl::ShaderStageType shaderStage = static_cast<nzsl::ShaderStageType>(i);
|
||||
if (shaderStages.Test(shaderStage))
|
||||
{
|
||||
NazaraAssert(shaderStages == shaderStage, "when supplying GLSL, only one shader stage type can be specified");
|
||||
NazaraAssert(shaderStages == shaderStage, "when supplying GLSL, only one shader stage type can be specified");
|
||||
|
||||
auto& entry = m_shaders.emplace_back();
|
||||
entry.shader = GlslShader{ std::string(reinterpret_cast<const char*>(source), std::size_t(sourceSize)) };
|
||||
entry.stage = shaderStage;
|
||||
break;
|
||||
}
|
||||
auto& entry = m_shaders.emplace_back();
|
||||
entry.shader = GlslShader{ std::string(reinterpret_cast<const char*>(source), std::size_t(sourceSize)) };
|
||||
entry.stage = shaderStage;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -184,15 +180,11 @@ namespace Nz
|
|||
|
||||
nzsl::Ast::ModulePtr sanitized = nzsl::Ast::Sanitize(shaderModule, options);
|
||||
|
||||
for (std::size_t i = 0; i < nzsl::ShaderStageTypeCount; ++i)
|
||||
for (nzsl::ShaderStageType shaderStage : shaderStages)
|
||||
{
|
||||
nzsl::ShaderStageType shaderStage = static_cast<nzsl::ShaderStageType>(i);
|
||||
if (shaderStages.Test(shaderStage))
|
||||
{
|
||||
auto& entry = m_shaders.emplace_back();
|
||||
entry.shader = ShaderStatement{ sanitized };
|
||||
entry.stage = shaderStage;
|
||||
}
|
||||
auto& entry = m_shaders.emplace_back();
|
||||
entry.shader = ShaderStatement{ sanitized };
|
||||
entry.stage = shaderStage;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue