Compare commits

...

2 Commits

Author SHA1 Message Date
Anish Bhobe 4cdb39c6ba Change name for pipeline creation. 2025-05-31 11:51:21 +02:00
Anish Bhobe cc1fd12b64 fix: Async Compute 2025-05-28 20:58:00 +02:00
5 changed files with 14 additions and 10 deletions

View File

@ -386,7 +386,7 @@ struct Frame
// TODO: ThreadSafe // TODO: ThreadSafe
_internal::GraphicsContextPool m_PrimaryPool; _internal::GraphicsContextPool m_PrimaryPool;
_internal::TransferContextPool m_AsyncTransferPool; _internal::TransferContextPool m_AsyncTransferPool;
_internal::ContextPool m_AsyncComputePool; _internal::ComputeContextPool m_AsyncComputePool;
vk::Fence m_FrameAvailableFence; vk::Fence m_FrameAvailableFence;
vk::Semaphore m_ImageAcquireSem; vk::Semaphore m_ImageAcquireSem;
@ -402,6 +402,7 @@ struct Frame
void Reset(u32 imageIdx, vk::Image swapchainImage, vk::ImageView swapchainImageView, Size2D swapchainSize); void Reset(u32 imageIdx, vk::Image swapchainImage, vk::ImageView swapchainImageView, Size2D swapchainSize);
GraphicsContext CreateGraphicsContext(); GraphicsContext CreateGraphicsContext();
TransferContext CreateAsyncTransferContext(); TransferContext CreateAsyncTransferContext();
ComputeContext CreateAsyncComputeContext();
void WaitUntilReady(); void WaitUntilReady();
Frame() = default; Frame() = default;
@ -541,15 +542,12 @@ class Device final
PipelineCreationError PipelineCreationError
CreateShaders(eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut, CreateShaders(eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut,
Slang::ComPtr<slang::IComponentType> &program, std::span<ShaderInfo const> const &shaders); Slang::ComPtr<slang::IComponentType> &program, std::span<ShaderInfo const> const &shaders);
systems::PipelineCreationError
CreateShader(vk::PipelineShaderStageCreateInfo &shadersOut, Slang::ComPtr<slang::IComponentType> &program,
ShaderInfo const &shaders);
PipelineCreationError PipelineCreationError
CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, Slang::ComPtr<slang::IComponentType> const &program); CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, Slang::ComPtr<slang::IComponentType> const &program);
public: public:
// Pipelines, unlike the other resources, are not ref-counted. // Pipelines, unlike the other resources, are not ref-counted.
PipelineCreationError CreatePipeline(Pipeline &pipeline, GraphicsPipelineCreateInfo const &createInfo); PipelineCreationError CreateGraphicsPipeline(Pipeline &pipeline, GraphicsPipelineCreateInfo const &createInfo);
PipelineCreationError CreateComputePipeline(Pipeline &pipeline, ComputePipelineCreateInfo const &createInfo); PipelineCreationError CreateComputePipeline(Pipeline &pipeline, ComputePipelineCreateInfo const &createInfo);
// //

View File

@ -502,7 +502,7 @@ systems::Device::CreateSampler(SamplerCreateInfo const &createInfo)
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreatePipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo) systems::Device::CreateGraphicsPipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo)
{ {
eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders; eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders;
Slang::ComPtr<slang::IComponentType> program; Slang::ComPtr<slang::IComponentType> program;
@ -1286,6 +1286,12 @@ systems::Frame::CreateAsyncTransferContext()
return m_AsyncTransferPool.CreateTransferContext(); return m_AsyncTransferPool.CreateTransferContext();
} }
systems::ComputeContext
systems::Frame::CreateAsyncComputeContext()
{
return m_AsyncComputePool.CreateComputeContext();
}
void void
systems::Frame::WaitUntilReady() systems::Frame::WaitUntilReady()
{ {

View File

@ -62,7 +62,7 @@ main(int, char **)
}}; }};
Pipeline pipeline; Pipeline pipeline;
auto pipelineError = device.CreatePipeline(pipeline, { auto pipelineError = device.CreateGraphicsPipeline(pipeline, {
.m_VertexInputs = {{ .m_VertexInputs = {{
.m_Attribute = Vertex::GetAttributes(), .m_Attribute = Vertex::GetAttributes(),
.m_Stride = sizeof(Vertex), .m_Stride = sizeof(Vertex),

View File

@ -127,7 +127,7 @@ main(int, char **)
Pipeline pipeline; Pipeline pipeline;
auto pipelineResult = auto pipelineResult =
device.CreatePipeline(pipeline, {.m_Shaders = { device.CreateGraphicsPipeline(pipeline, {.m_Shaders = {
{.m_ShaderFile = SHADER_FILE, .m_EntryPoints = {"vsmain", "fsmain"}}, {.m_ShaderFile = SHADER_FILE, .m_EntryPoints = {"vsmain", "fsmain"}},
}}); }});
ERROR_IF(pipelineResult, "Could not create pipeline. Cause: {}", pipelineResult.What()) ERROR_IF(pipelineResult, "Could not create pipeline. Cause: {}", pipelineResult.What())

View File

@ -184,7 +184,7 @@ main(int, char **)
auto attachmentFormat = device.m_Swapchain.m_Format; auto attachmentFormat = device.m_Swapchain.m_Format;
Pipeline pipeline; Pipeline pipeline;
if (auto result = device.CreatePipeline(pipeline, { if (auto result = device.CreateGraphicsPipeline(pipeline, {
.m_Shaders = {{ .m_Shaders = {{
.m_ShaderFile = MODEL_SHADER_FILE, .m_ShaderFile = MODEL_SHADER_FILE,
.m_EntryPoints = {"vsmain", "fsmain"}, .m_EntryPoints = {"vsmain", "fsmain"},
@ -196,7 +196,7 @@ main(int, char **)
} }
Pipeline backgroundPipeline; Pipeline backgroundPipeline;
if (auto result = device.CreatePipeline( if (auto result = device.CreateGraphicsPipeline(
backgroundPipeline, { backgroundPipeline, {
.m_Shaders = {{ .m_Shaders = {{
.m_ShaderFile = BACKGROUND_SHADER_FILE, .m_ShaderFile = BACKGROUND_SHADER_FILE,