Skip to content

Commit

Permalink
feat: fix vulkan stall in linux (#83)
Browse files Browse the repository at this point in the history
* feat: fix vulkan stall in linux

Signed-off-by: Michael Pollind <[email protected]>

* feat: add vulkan check

Signed-off-by: Michael Pollind <[email protected]>

---------

Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend authored Sep 23, 2023
1 parent 32a8f0d commit f949f9a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
1 change: 1 addition & 0 deletions HPL2/include/graphics/ForgeRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace hpl {

void InitializeRenderer(window::NativeWindowWrapper* window);
void InitializeResource();
RendererApi GetApi();

struct SamplerPoolKey {
union {
Expand Down
42 changes: 21 additions & 21 deletions HPL2/resource/deferred_resources.h.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,27 @@ STRUCT(UniformObject)
};
#endif

RES(Tex2D(float4), diffuseMap, UPDATE_FREQ_PER_BATCH, t2, binding = 3);
RES(Tex2D(float4), normalMap, UPDATE_FREQ_PER_BATCH, t3, binding = 4);
RES(Tex2D(float4), specularMap, UPDATE_FREQ_PER_BATCH, t4, binding = 5);
RES(Tex2D(float4), alphaMap, UPDATE_FREQ_PER_BATCH, t5, binding = 6);
RES(Tex2D(float4), heightMap, UPDATE_FREQ_PER_BATCH, t6, binding = 7);
RES(Tex2D(float4), illuminationMap, UPDATE_FREQ_PER_BATCH, t7, binding = 8);
RES(TexCube(float4), cubeMap, UPDATE_FREQ_PER_BATCH, t8, binding = 9);
RES(Tex2D(float4), dissolveAlphaMap, UPDATE_FREQ_PER_BATCH, t9, binding = 10);
RES(Tex2D(float4), cubeMapAlpha, UPDATE_FREQ_PER_BATCH, t10, binding = 11);

RES(SamplerState, refractionSampler, UPDATE_FREQ_NONE, s1, binding = 12);
RES(SamplerState, dissolveSampler, UPDATE_FREQ_NONE, s2, binding = 13);
RES(SamplerState, nearestSampler, UPDATE_FREQ_NONE, s3, binding = 14);
RES(SamplerState, materialSampler, UPDATE_FREQ_NONE, s4, binding = 15);

RES(Tex2D(float4), dissolveMap, UPDATE_FREQ_NONE, t11, binding = 16);

RES(Buffer(UniformMaterial), uniformMaterialBuffer, UPDATE_FREQ_PER_FRAME, t0, binding = 1);
RES(Buffer(UniformObject), uniformObjectBuffer, UPDATE_FREQ_PER_FRAME, t1, binding = 2);
RES(Tex2D(float4), refractionMap, UPDATE_FREQ_PER_FRAME, t12, binding = 18);
RES(Tex2D(float4), reflectionMap[4], UPDATE_FREQ_PER_FRAME, t13, binding = 19);
RES(Tex2D(float4), diffuseMap, UPDATE_FREQ_PER_BATCH, t2, binding = 1);
RES(Tex2D(float4), normalMap, UPDATE_FREQ_PER_BATCH, t3, binding = 2);
RES(Tex2D(float4), specularMap, UPDATE_FREQ_PER_BATCH, t4, binding = 3);
RES(Tex2D(float4), alphaMap, UPDATE_FREQ_PER_BATCH, t5, binding = 4);
RES(Tex2D(float4), heightMap, UPDATE_FREQ_PER_BATCH, t6, binding = 5);
RES(Tex2D(float4), illuminationMap, UPDATE_FREQ_PER_BATCH, t7, binding = 6);
RES(TexCube(float4), cubeMap, UPDATE_FREQ_PER_BATCH, t8, binding = 7);
RES(Tex2D(float4), dissolveAlphaMap, UPDATE_FREQ_PER_BATCH, t9, binding = 8);
RES(Tex2D(float4), cubeMapAlpha, UPDATE_FREQ_PER_BATCH, t10, binding = 9);

RES(SamplerState, refractionSampler, UPDATE_FREQ_NONE, s1, binding = 10);
RES(SamplerState, dissolveSampler, UPDATE_FREQ_NONE, s2, binding = 11);
RES(SamplerState, nearestSampler, UPDATE_FREQ_NONE, s3, binding = 12);
RES(SamplerState, materialSampler, UPDATE_FREQ_NONE, s4, binding = 13);

RES(Tex2D(float4), dissolveMap, UPDATE_FREQ_NONE, t11, binding = 14);

RES(Buffer(UniformMaterial), uniformMaterialBuffer, UPDATE_FREQ_PER_FRAME, t0, binding = 15);
RES(Buffer(UniformObject), uniformObjectBuffer, UPDATE_FREQ_PER_FRAME, t1, binding = 16);
RES(Tex2D(float4), refractionMap, UPDATE_FREQ_PER_FRAME, t12, binding = 17);
RES(Tex2D(float4), reflectionMap[4], UPDATE_FREQ_PER_FRAME, t13, binding = 18);

PUSH_CONSTANT(materialRootConstant, b0)
{
Expand Down
8 changes: 6 additions & 2 deletions HPL2/sources/graphics/ForgeRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
#endif
#include "renderdoc_app.h"
#endif
extern RendererApi gSelectedRendererApi;

namespace hpl {
RendererApi ForgeRenderer::GetApi() {
return gSelectedRendererApi;
}

void ForgeRenderer::IncrementFrame() {
// Stall if CPU is running "Swap Chain Buffer Count" frames ahead of GPU
Expand Down Expand Up @@ -58,7 +62,7 @@ namespace hpl {
{
cmdBindRenderTargets(frame.m_cmd, 1, &swapChainTarget, NULL, NULL, NULL, NULL, -1, -1);
uint32_t rootConstantIndex = getDescriptorIndexFromName(m_finalRootSignature , "uRootConstants");

cmdSetViewport(frame.m_cmd, 0.0f, 0.0f, static_cast<float>(swapChainTarget->mWidth), static_cast<float>(swapChainTarget->mHeight), 0.0f, 1.0f);
cmdSetScissor(frame.m_cmd, 0, 0, static_cast<float>(swapChainTarget->mWidth), static_cast<float>(swapChainTarget->mHeight));
cmdBindPipeline(frame.m_cmd, m_finalPipeline.m_handle);
Expand Down Expand Up @@ -121,7 +125,7 @@ namespace hpl {
assert(ret == 1);
}
#endif

#endif

initRenderer("test", &desc, &m_renderer);
Expand Down
7 changes: 6 additions & 1 deletion HPL2/sources/graphics/RendererDeferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2508,8 +2508,13 @@ namespace hpl {
cmdSetScissor(cmd, 0, 0, outputBuffer->mWidth, outputBuffer->mHeight);
cmdBindPipeline(cmd, options.m_invert ? m_solidIlluminationPipelineCW.m_handle: m_solidIlluminationPipelineCCW.m_handle);

//cmdBindDescriptorSet(cmd, frameDescriptorIndex, m_materialSet.m_frameSet[frame.m_frameIndex].m_handle);

// for DirectX12 these frame descriptors are not used so its ommitied for the draw
#if defined(VULKAN)
if (frame.m_renderer->GetApi() == RENDERER_API_VULKAN) {
cmdBindDescriptorSet(cmd, frameDescriptorIndex, m_materialSet.m_frameSet[frame.m_frameIndex].m_handle);
}
#endif
for (auto& illuminationItem : m_rendererList.GetRenderableItems(eRenderListType_Illumination)) {
cMaterial* pMaterial = illuminationItem->GetMaterial();
iVertexBuffer* vertexBuffer = illuminationItem->GetVertexBuffer();
Expand Down

0 comments on commit f949f9a

Please sign in to comment.