Fixed most vulkan validation layers

This commit is contained in:
antopilo
2025-04-15 19:33:46 -04:00
parent 710d63ad98
commit a46ee129f0
23 changed files with 59 additions and 50 deletions

View File

@@ -80,7 +80,8 @@ struct CameraView {
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;
struct PSInput {
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -90,7 +90,8 @@ struct CopyPushConstant
CopyPushConstant pushConstants;
// Outputs
struct VSOutput {
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -80,12 +80,14 @@ struct CameraView {
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;
struct PSInput {
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
struct PSOutput
{
float4 oColor0 : SV_TARGET;
float4 oEntityID : SV_TARGET1;
};

View File

@@ -92,7 +92,8 @@ struct DebugConstant
DebugConstant pushConstants;
// Outputs
struct VSOutput {
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -80,12 +80,14 @@ struct CameraView {
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;
struct PSInput {
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
struct PSOutput
{
float4 oColor0 : SV_TARGET;
};

View File

@@ -90,7 +90,8 @@ struct LineConstant
LineConstant pushConstants;
// Outputs
struct VSOutput {
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -80,7 +80,8 @@ struct CameraView {
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;
struct PSInput {
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -94,7 +94,8 @@ struct OutlinePushConstant
OutlinePushConstant pushConstants;
// Outputs
struct VSOutput {
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -80,7 +80,8 @@ struct CameraView {
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;
struct PSInput {
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -97,7 +97,8 @@ struct ShadingPushConstant
ShadingPushConstant pushConstants;
// Outputs
struct VSOutput {
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};

View File

@@ -80,14 +80,11 @@ struct CameraView {
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;
struct PSInput {
struct PSInput
{
float4 Position : SV_Position;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct ModelPushConstant
{
int modelIndex; // Push constant data
@@ -98,8 +95,6 @@ struct ModelPushConstant
[[vk::push_constant]]
ModelPushConstant pushConstants;
PSOutput main(PSInput input)
void main(PSInput input)
{
PSOutput output;
return output;
}

View File

@@ -91,7 +91,8 @@ struct ModelPushConstant
ModelPushConstant pushConstants;
// Outputs
struct VSOutput {
struct VSOutput
{
float4 Position : SV_Position;
};

View File

@@ -16,7 +16,7 @@ cbuffer ubo : register(b0, space0) { UBO ubo; }
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Color : COLOR0;
[[vk::location(0)]] float3 Color : COLOR0;
};
VSOutput main(VSInput input, uint VertexIndex : SV_VertexID)

View File

@@ -80,12 +80,13 @@ struct CameraView {
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;
struct PSInput {
struct PSInput
{
float4 Position : SV_Position;
float3 Color : TEXCOORD0;
float2 UV : TEXCOORD1;
float3 Normal : TEXCOORD2;
float3x3 TBN : TEXCOORD3;
//float3x3 TBN : TEXCOORD3;
};
struct PSOutput {
@@ -118,7 +119,7 @@ PSOutput main(PSInput input)
{
// Sample from texture.
}
normal = mul(input.TBN, normal);
//normal = mul(input.TBN, normal);
normal = input.Normal / 2.0f + 0.5f;
output.oNormal = float4(normal, 1.0f);

View File

@@ -92,12 +92,13 @@ struct ModelPushConstant
ModelPushConstant pushConstants;
// Outputs
struct VSOutput {
struct VSOutput
{
float4 Position : SV_Position;
float3 Color : TEXCOORD0;
float2 UV : TEXCOORD1;
float3 Normal : TEXCOORD2;
float3x3 TBN : TEXCOORD3;
//float3x3 TBN : TEXCOORD3;
};
// Main vertex shader
@@ -117,9 +118,9 @@ VSOutput main(uint vertexIndex : SV_VertexID)
output.UV = float2(v.uv_x, v.uv_y);
output.Normal = normalize(v.normal);
float3 T = normalize(mul((float3x3)modelData.model, normalize(v.tangent.xyz)));
float3 B = normalize(mul((float3x3)modelData.model, normalize(v.bitangent.xyz)));
float3 N = normalize(mul((float3x3)modelData.model, normalize(v.normal)).xyz);
output.TBN = transpose(float3x3(T, B, N));
//float3 T = normalize(mul((float3x3)modelData.model, normalize(v.tangent.xyz)));
//float3 B = normalize(mul((float3x3)modelData.model, normalize(v.bitangent.xyz)));
//float3 N = normalize(mul((float3x3)modelData.model, normalize(v.normal)).xyz);
//output.TBN = transpose(float3x3(T, B, N));
return output;
}

View File

@@ -431,8 +431,6 @@ namespace Nuake
return; // We don't care about this file type, we dont support it.
}
Logger::Log("Adding " + file->GetName() + " to manifest", "manifest", VERBOSE);
// Register the resource in the manifest
const std::string& path = file->GetRelativePath();
const UUID uuid = resolverManager.ResolveUUID(file);

View File

@@ -67,7 +67,7 @@ namespace Nuake
{
private:
std::string Name;
bool HasDepthTest = true;
bool HasDepthTest = false;
Ref<VulkanShader> VertShader;
Ref<VulkanShader> FragShader;

View File

@@ -180,7 +180,7 @@ void PipelineBuilder::SetColorAttachments(std::vector<VkFormat>& formats)
void PipelineBuilder::SetLineRendering(bool enabled)
{
if (enabled)
if (enabled)
{
LineRasterization = {};
LineRasterization.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_KHR;
@@ -190,7 +190,7 @@ void PipelineBuilder::SetLineRendering(bool enabled)
}
else
{
RenderInfo.pNext = nullptr;
RenderInfo.pNext = nullptr;
}
}
@@ -204,7 +204,7 @@ void PipelineBuilder::DisableDepthTest()
DepthStencil.depthTestEnable = VK_FALSE;
DepthStencil.depthWriteEnable = VK_FALSE;
DepthStencil.depthCompareOp = VK_COMPARE_OP_NEVER;
DepthStencil.depthBoundsTestEnable = VK_FALSE;
DepthStencil.depthBoundsTestEnable = VK_FALSE;
DepthStencil.stencilTestEnable = VK_FALSE;
DepthStencil.front = {};
DepthStencil.back = {};

View File

@@ -29,6 +29,7 @@ ShadowRenderPipeline::ShadowRenderPipeline()
ShadowPipeline = RenderPipeline();
auto& shadowPass = ShadowPipeline.AddPass("Shadow");
shadowPass.AddAttachment("Depth", ImageFormat::D32F, ImageUsage::Depth, true);
shadowPass.SetDepthTest(true);
shadowPass.SetShaders(shaderMgr.GetShader("shadow_vert"), shaderMgr.GetShader("shadow_frag"));
shadowPass.SetPushConstant<GBufferConstant>(gbufferConstant);
shadowPass.SetPreRender([&](PassRenderContext& ctx) {
@@ -295,7 +296,7 @@ void SceneRenderPipeline::Render(PassRenderContext& ctx)
void* mappedData;
vmaMapMemory(VulkanAllocator::Get().GetAllocator(), stagingBuffer->GetAllocation(), &mappedData);
Vector4 entityID = *reinterpret_cast<Vector4*>(mappedData);
Vector4 entityID = *reinterpret_cast<Vector4*>(mappedData);
vmaUnmapMemory(VulkanAllocator::Get().GetAllocator(), stagingBuffer->GetAllocation());
request.callback(static_cast<int>(entityID.r));
@@ -312,6 +313,7 @@ void SceneRenderPipeline::RecreatePipeline()
GBufferPipeline = RenderPipeline();
auto& gBufferPass = GBufferPipeline.AddPass("GBuffer");
gBufferPass.SetShaders(shaderMgr.GetShader("basic_vert"), shaderMgr.GetShader("basic_frag"));
gBufferPass.SetDepthTest(true);
gBufferPass.AddAttachment("Albedo", GBufferAlbedo->GetFormat());
gBufferPass.AddAttachment("Normal", GBufferNormal->GetFormat());
gBufferPass.AddAttachment("Material", GBufferMaterial->GetFormat());
@@ -580,7 +582,7 @@ void SceneRenderPipeline::RecreatePipeline()
gizmoPass.SetPushConstant<DebugConstant>(debugConstant);
gizmoPass.AddInput("Depth");
gizmoPass.AddAttachment("GizmoOutput", GizmoOutput->GetFormat());
gizmoPass.AddAttachment("GizmoEntityID", GBufferEntityID->GetFormat(), ImageUsage::ColorAttachment, false);
gizmoPass.AddAttachment("GizmoEntityID", GBufferEntityID->GetFormat(), ImageUsage::Default, false);
gizmoPass.AddAttachment("GizmoDepth", GBufferDepth->GetFormat(), ImageUsage::Depth, false);
gizmoPass.SetDepthTest(true);
gizmoPass.SetPreRender([&](PassRenderContext& ctx)

View File

@@ -190,6 +190,7 @@ namespace Nuake
MulticastDelegate<DebugCmd&> DebugDrawDelegate;
MulticastDelegate<DebugLineCmd&> DebugLineDrawDelegate;
public:
SceneRenderPipeline();
~SceneRenderPipeline() = default;

View File

@@ -125,7 +125,7 @@ Ref<VulkanShader> ShaderCompiler::CompileShader(const std::string& path)
const char* errorMsg = reinterpret_cast<const char*>(errorBlobUtf8->GetBufferPointer());
std::string errorMsgStr(errorMsg, errorBlobUtf8->GetBufferSize());
Logger::Log("Shader compilation failed: " + errorMsgStr, "DXC", CRITICAL);
Logger::Log("Shader compilation failed: " + errorMsgStr, "DXC", CRITICAL);
throw std::runtime_error("Shader compilation failed: " + errorMsgStr);
}

View File

@@ -126,14 +126,10 @@ void VkRenderer::Initialize()
camData.View = Matrix4(1.0f);
camData.Projection = Matrix4(1.0f);
// init camera buffer
InitDescriptors();
InitImgui();
SceneRenderer = CreateRef<VkSceneRenderer>();
SceneRenderer->Init();
IsInitialized = true;
}
@@ -203,8 +199,7 @@ void VkRenderer::SelectGPU()
{
VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
VK_KHR_LINE_RASTERIZATION_EXTENSION_NAME,
VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME,
VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME
};
auto systemInfoRet = vkb::SystemInfo::get_system_info();
@@ -228,7 +223,7 @@ void VkRenderer::SelectGPU()
.set_required_features_12(features12)
.set_required_features(VkPhysicalDeviceFeatures{
.fillModeNonSolid = VK_TRUE,
.wideLines = VK_TRUE
})
.set_surface(Surface)
.add_required_extensions(requiredExtensions)
@@ -401,8 +396,12 @@ void VkRenderer::PrepareSceneData(RenderContext ctx)
{
scenes.push_back(scene);
}
SceneRenderer->PrepareScenes(scenes, ctx);
// Maybe this shouldnt be in a scene renderer
if (!SceneRenderers.empty())
{
SceneRenderers.begin()->second->PrepareScenes(scenes, ctx);
}
}
void VkRenderer::DrawScenes()

View File

@@ -175,7 +175,6 @@ namespace Nuake
VkCommandPool ImguiCommandPool;
std::map<UUID, Ref<VkSceneRenderer>> SceneRenderers;
Ref<VkSceneRenderer> SceneRenderer;
public:
static VkRenderer& Get()