summaryrefslogtreecommitdiff
path: root/tools/gfx/vulkan/vk-pipeline-state.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /tools/gfx/vulkan/vk-pipeline-state.cpp
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'tools/gfx/vulkan/vk-pipeline-state.cpp')
-rw-r--r--tools/gfx/vulkan/vk-pipeline-state.cpp89
1 files changed, 50 insertions, 39 deletions
diff --git a/tools/gfx/vulkan/vk-pipeline-state.cpp b/tools/gfx/vulkan/vk-pipeline-state.cpp
index 2e7bb1c0a..8fd0c5680 100644
--- a/tools/gfx/vulkan/vk-pipeline-state.cpp
+++ b/tools/gfx/vulkan/vk-pipeline-state.cpp
@@ -2,12 +2,11 @@
#include "vk-pipeline-state.h"
#include "vk-device.h"
-#include "vk-shader-program.h"
+#include "vk-helper-functions.h"
#include "vk-shader-object-layout.h"
+#include "vk-shader-program.h"
#include "vk-vertex-layout.h"
-#include "vk-helper-functions.h"
-
namespace gfx
{
@@ -35,9 +34,15 @@ PipelineStateImpl::~PipelineStateImpl()
}
}
-void PipelineStateImpl::establishStrongDeviceReference() { m_device.establishStrongReference(); }
+void PipelineStateImpl::establishStrongDeviceReference()
+{
+ m_device.establishStrongReference();
+}
-void PipelineStateImpl::comFree() { m_device.breakStrongReference(); }
+void PipelineStateImpl::comFree()
+{
+ m_device.breakStrongReference();
+}
void PipelineStateImpl::init(const GraphicsPipelineStateDesc& inDesc)
{
@@ -159,8 +164,8 @@ Result PipelineStateImpl::createVKGraphicsPipelineState()
multisampling.alphaToCoverageEnable = blendDesc.alphaToCoverageEnable;
multisampling.alphaToOneEnable = VK_FALSE;
- auto targetCount =
- GfxCount(Math::Min(framebufferLayoutImpl->m_renderTargetCount, (uint32_t)blendDesc.targetCount));
+ auto targetCount = GfxCount(
+ Math::Min(framebufferLayoutImpl->m_renderTargetCount, (uint32_t)blendDesc.targetCount));
List<VkPipelineColorBlendAttachmentState> colorBlendTargets;
// Regardless of whether blending is enabled, Vulkan always applies the color write mask
@@ -222,7 +227,8 @@ Result PipelineStateImpl::createVKGraphicsPipelineState()
dynamicStates.add(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
// It's not valid to specify VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT when
// the pipeline contains a mesh shader.
- if (!m_program->isMeshShaderProgram() && m_device->m_api.m_extendedFeatures.extendedDynamicStateFeatures.extendedDynamicState)
+ if (!m_program->isMeshShaderProgram() &&
+ m_device->m_api.m_extendedFeatures.extendedDynamicStateFeatures.extendedDynamicState)
{
dynamicStates.add(VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT);
@@ -275,17 +281,21 @@ Result PipelineStateImpl::createVKGraphicsPipelineState()
if (m_device->m_pipelineCreationAPIDispatcher)
{
- SLANG_RETURN_ON_FAIL(
- m_device->m_pipelineCreationAPIDispatcher->createGraphicsPipelineState(
- m_device,
- programImpl->linkedProgram.get(),
- &pipelineInfo,
- (void**)&m_pipeline));
+ SLANG_RETURN_ON_FAIL(m_device->m_pipelineCreationAPIDispatcher->createGraphicsPipelineState(
+ m_device,
+ programImpl->linkedProgram.get(),
+ &pipelineInfo,
+ (void**)&m_pipeline));
}
else
{
SLANG_VK_RETURN_ON_FAIL(m_device->m_api.vkCreateGraphicsPipelines(
- m_device->m_device, pipelineCache, 1, &pipelineInfo, nullptr, &m_pipeline));
+ m_device->m_device,
+ pipelineCache,
+ 1,
+ &pipelineInfo,
+ nullptr,
+ &m_pipeline));
}
return SLANG_OK;
@@ -300,24 +310,28 @@ Result PipelineStateImpl::createVKComputePipelineState()
}
VkComputePipelineCreateInfo computePipelineInfo = {
- VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO};
+ VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO};
computePipelineInfo.stage = programImpl->m_stageCreateInfos[0];
computePipelineInfo.layout = programImpl->m_rootObjectLayout->m_pipelineLayout;
if (m_device->m_pipelineCreationAPIDispatcher)
{
- SLANG_RETURN_ON_FAIL(
- m_device->m_pipelineCreationAPIDispatcher->createComputePipelineState(
- m_device,
- programImpl->linkedProgram.get(),
- &computePipelineInfo,
- (void**)&m_pipeline));
+ SLANG_RETURN_ON_FAIL(m_device->m_pipelineCreationAPIDispatcher->createComputePipelineState(
+ m_device,
+ programImpl->linkedProgram.get(),
+ &computePipelineInfo,
+ (void**)&m_pipeline));
}
else
{
VkPipelineCache pipelineCache = VK_NULL_HANDLE;
SLANG_VK_RETURN_ON_FAIL(m_device->m_api.vkCreateComputePipelines(
- m_device->m_device, pipelineCache, 1, &computePipelineInfo, nullptr, &m_pipeline));
+ m_device->m_device,
+ pipelineCache,
+ 1,
+ &computePipelineInfo,
+ nullptr,
+ &m_pipeline));
}
return SLANG_OK;
}
@@ -329,13 +343,9 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
switch (desc.type)
{
- case PipelineType::Compute:
- return createVKComputePipelineState();
- case PipelineType::Graphics:
- return createVKGraphicsPipelineState();
- default:
- SLANG_UNREACHABLE("Unknown pipeline type.");
- return SLANG_FAIL;
+ case PipelineType::Compute: return createVKComputePipelineState();
+ case PipelineType::Graphics: return createVKGraphicsPipelineState();
+ default: SLANG_UNREACHABLE("Unknown pipeline type."); return SLANG_FAIL;
}
}
SLANG_NO_THROW Result SLANG_MCALL PipelineStateImpl::getNativeHandle(InteropHandle* outHandle)
@@ -349,9 +359,11 @@ SLANG_NO_THROW Result SLANG_MCALL PipelineStateImpl::getNativeHandle(InteropHand
RayTracingPipelineStateImpl::RayTracingPipelineStateImpl(DeviceImpl* device)
: PipelineStateImpl(device)
-{}
+{
+}
uint32_t RayTracingPipelineStateImpl::findEntryPointIndexByName(
- const Dictionary<String, Index>& entryPointNameToIndex, const char* name)
+ const Dictionary<String, Index>& entryPointNameToIndex,
+ const char* name)
{
if (!name)
return VK_SHADER_UNUSED_KHR;
@@ -451,7 +463,8 @@ Result RayTracingPipelineStateImpl::createVKRayTracingPipelineState()
if (m_device->m_pipelineCreationAPIDispatcher)
{
m_device->m_pipelineCreationAPIDispatcher->beforeCreateRayTracingState(
- m_device, programImpl->linkedProgram.get());
+ m_device,
+ programImpl->linkedProgram.get());
}
VkPipelineCache pipelineCache = VK_NULL_HANDLE;
@@ -468,7 +481,8 @@ Result RayTracingPipelineStateImpl::createVKRayTracingPipelineState()
if (m_device->m_pipelineCreationAPIDispatcher)
{
m_device->m_pipelineCreationAPIDispatcher->afterCreateRayTracingState(
- m_device, programImpl->linkedProgram.get());
+ m_device,
+ programImpl->linkedProgram.get());
}
return SLANG_OK;
}
@@ -479,11 +493,8 @@ Result RayTracingPipelineStateImpl::ensureAPIPipelineStateCreated()
switch (desc.type)
{
- case PipelineType::RayTracing:
- return createVKRayTracingPipelineState();
- default:
- SLANG_UNREACHABLE("Unknown pipeline type.");
- return SLANG_FAIL;
+ case PipelineType::RayTracing: return createVKRayTracingPipelineState();
+ default: SLANG_UNREACHABLE("Unknown pipeline type."); return SLANG_FAIL;
}
}
Result RayTracingPipelineStateImpl::getNativeHandle(InteropHandle* outHandle)