Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Game-Lib/Game-Lib/Editor/Viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Editor
vec2 _lastPanelSize = vec2(1920, 1080);

vec2 _viewportPos = vec2(0, 0);
vec2 _viewportSize = vec2(0, 0);
vec2 _viewportSize = vec2(1920, 1080);

bool _rightClickStartedInViewport = false;
};
Expand Down
5 changes: 1 addition & 4 deletions Source/Game-Lib/Game-Lib/Rendering/CulledRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ void CulledRenderer::OccluderPass(OccluderPassParams& params)
params.occluderFillDescriptorSet.Bind("_culledDrawCallsBitMask"_h, params.culledDrawCallsBitMaskBuffer);

// Bind descriptorset
params.commandList->BindDescriptorSet(params.globalDescriptorSet, params.frameIndex);
params.commandList->BindDescriptorSet(params.occluderFillDescriptorSet, params.frameIndex);

params.commandList->Dispatch((numInstances + 31) / 32, 1, 1);
Expand Down Expand Up @@ -166,7 +165,6 @@ void CulledRenderer::OccluderPass(OccluderPassParams& params)
cullConstants->drawCallDataSize = params.drawCallDataSize;
params.commandList->PushConstant(cullConstants, 0, sizeof(CullConstants));

params.commandList->BindDescriptorSet(params.globalDescriptorSet, params.frameIndex);
params.commandList->BindDescriptorSet(params.createIndirectDescriptorSet, params.frameIndex);

if (debugOrdered)
Expand Down Expand Up @@ -453,7 +451,6 @@ void CulledRenderer::CullingPass(CullingPassParams& params)
params.commandList->PushConstant(cullConstants, 0, sizeof(CullConstants));

params.commandList->BindDescriptorSet(params.debugDescriptorSet, params.frameIndex);
params.commandList->BindDescriptorSet(params.globalDescriptorSet, params.frameIndex);
params.commandList->BindDescriptorSet(params.createIndirectAfterCullSet, params.frameIndex);

if (debugOrdered)
Expand Down Expand Up @@ -604,7 +601,7 @@ void CulledRenderer::GeometryPass(GeometryPassParams& params)
FillDrawCallConstants* fillConstants = params.graphResources->FrameNew<FillDrawCallConstants>();
fillConstants->numTotalDraws = numDrawCalls;
fillConstants->bitmaskOffset = i * params.cullingResources->GetBitMaskBufferUintsPerView();
fillConstants->diffAgainstPrev = 1; // Geomeyry should diff against prev
fillConstants->diffAgainstPrev = 1; // Geometry should diff against prev
params.commandList->PushConstant(fillConstants, 0, sizeof(FillDrawCallConstants));

params.fillDescriptorSet.Bind("_culledDrawCallsBitMask"_h, params.culledDrawCallsBitMaskBuffer);
Expand Down
4 changes: 2 additions & 2 deletions Source/Game-Lib/Game-Lib/Rendering/CullingResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ bool CullingResourcesIndexedBase::SyncToGPU(bool forceRecount)
_cullingDescriptorSet.Bind("_drawCalls"_h, _drawCalls.GetBuffer());
if (_materialPassDescriptorSet != nullptr)
{
_materialPassDescriptorSet->Bind("_modelDraws"_h, _drawCalls.GetBuffer());
_materialPassDescriptorSet->Bind("_opaqueModelDraws"_h, _drawCalls.GetBuffer());
}

// (Re)create Culled Instance Counts Buffer
Expand Down Expand Up @@ -435,7 +435,7 @@ bool CullingResourcesNonIndexedBase::SyncToGPU(bool forceRecount)
_cullingDescriptorSet.Bind("_drawCalls"_h, _drawCalls.GetBuffer());
if (_materialPassDescriptorSet != nullptr)
{
_materialPassDescriptorSet->Bind("_modelDraws"_h, _drawCalls.GetBuffer());
_materialPassDescriptorSet->Bind("_opaqueModelDraws"_h, _drawCalls.GetBuffer());
}

// (Re)create Culled Instance Counts Buffer
Expand Down
3 changes: 0 additions & 3 deletions Source/Game-Lib/Game-Lib/Rendering/Debug/DebugRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ void DebugRenderer::Add2DPass(Renderer::RenderGraph* renderGraph, RenderResource
{
commandList.BeginPipeline(pipeline);

//commandList.BindDescriptorSet2(data.globalSet, frameIndex); // TODO: Enable this with validation layers and find a way to print a better warning that this shader doesn't need this descriptorset
commandList.BindDescriptorSet(data.drawSolid2DSet, frameIndex);

// Draw
Expand All @@ -319,7 +318,6 @@ void DebugRenderer::Add2DPass(Renderer::RenderGraph* renderGraph, RenderResource
{
commandList.BeginPipeline(pipeline);

//commandList.BindDescriptorSet2(data.globalSet, frameIndex); // TODO: Enable this with validation layers and find a way to print a better warning that this shader doesn't need this descriptorset
commandList.BindDescriptorSet(data.draw2DSet, frameIndex);

// Draw
Expand All @@ -333,7 +331,6 @@ void DebugRenderer::Add2DPass(Renderer::RenderGraph* renderGraph, RenderResource
{
commandList.BeginPipeline(pipeline);

//commandList.BindDescriptorSet2(data.globalSet, frameIndex); // TODO: Enable this with validation layers and find a way to print a better warning that this shader doesn't need this descriptorset
commandList.BindDescriptorSet(data.draw2DIndirectSet, frameIndex);

// Draw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void MaterialRenderer::CreatePermanentResources()
samplerDesc.shaderVisibility = Renderer::ShaderVisibility::ALL;

_sampler = _renderer->CreateSampler(samplerDesc);
_preEffectsPassDescriptorSet.Bind("_sampler"_h, _sampler);
_materialPassDescriptorSet.Bind("_sampler"_h, _sampler);

_directionalLights.SetDebugName("Directional Lights");
Expand Down
1 change: 1 addition & 0 deletions Source/Game-Lib/Game-Lib/Rendering/Model/ModelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ void ModelRenderer::RegisterMaterialPassBufferUsage(Renderer::RenderGraphBuilder
builder.Read(_opaqueCullingResources.GetDrawCalls().GetBuffer(), BufferUsage::COMPUTE);
builder.Read(_opaqueCullingResources.GetDrawCallDatas().GetBuffer(), BufferUsage::COMPUTE);
builder.Read(_opaqueCullingResources.GetInstanceRefs().GetBuffer(), BufferUsage::COMPUTE);
builder.Read(_opaqueCullingResources.GetCulledInstanceLookupTableBuffer(), BufferUsage::COMPUTE);
builder.Read(_vertices.GetBuffer(), BufferUsage::COMPUTE);
builder.Read(_indices.GetBuffer(), BufferUsage::COMPUTE);
builder.Read(_textureDatas.GetBuffer(), BufferUsage::COMPUTE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void TerrainRenderer::AddOccluderPass(Renderer::RenderGraph* renderGraph, Render
builder.Read(_instanceDatas.GetBuffer(), BufferUsage::COMPUTE | BufferUsage::GRAPHICS);
builder.Read(_vertices.GetBuffer(), BufferUsage::GRAPHICS);
builder.Read(_cellDatas.GetBuffer(), BufferUsage::GRAPHICS);
builder.Read(_chunkDatas.GetBuffer(), BufferUsage::GRAPHICS);
builder.Read(resources.cameras.GetBuffer(), BufferUsage::GRAPHICS);

data.culledInstanceBuffer = builder.Write(_culledInstanceBuffer, BufferUsage::TRANSFER | BufferUsage::COMPUTE | BufferUsage::GRAPHICS);
Expand Down Expand Up @@ -457,9 +458,10 @@ void TerrainRenderer::AddGeometryPass(Renderer::RenderGraph* renderGraph, Render
builder.Read(resources.cameras.GetBuffer(), BufferUsage::GRAPHICS);
builder.Read(_vertices.GetBuffer(), BufferUsage::GRAPHICS);
builder.Read(_cellDatas.GetBuffer(), BufferUsage::GRAPHICS);
builder.Read(_chunkDatas.GetBuffer(), BufferUsage::GRAPHICS);
if (cullingEnabled)
{
builder.Read(_instanceDatas.GetBuffer(), BufferUsage::COMPUTE);
builder.Read(_instanceDatas.GetBuffer(), BufferUsage::COMPUTE | BufferUsage::GRAPHICS);
}

data.argumentBuffer = builder.Write(_argumentBuffer, BufferUsage::TRANSFER | BufferUsage::GRAPHICS | BufferUsage::COMPUTE);
Expand Down Expand Up @@ -1124,7 +1126,7 @@ void TerrainRenderer::SyncToGPU()

if (_instanceDatas.SyncToGPU(_renderer))
{
resources.terrainDescriptorSet.Bind("_instanceDatas", _instanceDatas.GetBuffer());
resources.terrainDescriptorSet.Bind("_instanceDatas"_h, _instanceDatas.GetBuffer());
_occluderFillPassDescriptorSet.Bind("_instances"_h, _instanceDatas.GetBuffer());
_geometryFillPassDescriptorSet.Bind("_instances"_h, _instanceDatas.GetBuffer());
_cullingPassDescriptorSet.Bind("_instances"_h, _instanceDatas.GetBuffer());
Expand All @@ -1136,6 +1138,7 @@ void TerrainRenderer::SyncToGPU()
desc.name = "TerrainCulledInstanceBuffer";
_culledInstanceBuffer = _renderer->CreateBuffer(_culledInstanceBuffer, desc);

resources.terrainDescriptorSet.Bind("_culledInstanceDatas"_h, _culledInstanceBuffer);
_cullingPassDescriptorSet.Bind("_culledInstances"_h, _culledInstanceBuffer);
_occluderFillPassDescriptorSet.Bind("_culledInstances"_h, _culledInstanceBuffer);
_geometryFillPassDescriptorSet.Bind("_culledInstances"_h, _culledInstanceBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void TextureRenderer::AddTexturePass(Renderer::RenderGraph* renderGraph, RenderR
Renderer::TextureID textureID = Renderer::TextureID(texture);
ResolveMips(graphResources, commandList, frameIndex, data.mipResolveDescriptorSet, textureID);
}
//commandList.ImageBarrier()

// Reset the viewport and scissor
vec2 renderSize = _renderer->GetRenderSize();
Expand Down
2 changes: 1 addition & 1 deletion Source/Shaders/Shaders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ Solution.Util.CreateProject(mod.Name, "Utility", Solution.Projects.Current.BinDi
end)

vpaths {
["/*"] = { "*.lua", mod.Name .. "/**" }
["/*"] = { "*.lua", mod.Name }
}
end)
16 changes: 8 additions & 8 deletions Source/Shaders/Shaders/DescriptorSet/Model.inc.slang
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

[[vk::binding(0, MODEL)]] StructuredBuffer<uint> _opaqueCulledInstanceLookupTable; // One uint per instance, contains instanceRefID of what survives culling, and thus can get reordered
[[vk::binding(1, MODEL)]] StructuredBuffer<InstanceRef> _opaqueInstanceRefTable;
[[vk::binding(2, MODEL)]] StructuredBuffer<PackedTextureData> _packedModelTextureDatas;
[[vk::binding(3, MODEL)]] StructuredBuffer<PackedModelVertex> _packedModelVertices;
[[vk::binding(4, MODEL)]] StructuredBuffer<ModelInstanceData> _modelInstanceDatas;
[[vk::binding(5, MODEL)]] StructuredBuffer<float4x4> _modelInstanceMatrices;
[[vk::binding(6, MODEL)]] StructuredBuffer<float4x4> _instanceBoneMatrices;
[[vk::binding(7, MODEL)]] StructuredBuffer<float4x4> _instanceTextureTransformMatrices;
[[vk::binding(8, MODEL)]] RWStructuredBuffer<PackedAnimatedVertexPosition> _animatedModelVertexPositions;
[[vk::binding(9, MODEL)]] StructuredBuffer<IndexedDraw> _modelDraws;
[[vk::binding(2, MODEL)]] StructuredBuffer<IndexedDraw> _opaqueModelDraws;
[[vk::binding(3, MODEL)]] StructuredBuffer<PackedTextureData> _packedModelTextureDatas;
[[vk::binding(4, MODEL)]] StructuredBuffer<PackedModelVertex> _packedModelVertices;
[[vk::binding(5, MODEL)]] StructuredBuffer<ModelInstanceData> _modelInstanceDatas;
[[vk::binding(6, MODEL)]] StructuredBuffer<float4x4> _modelInstanceMatrices;
[[vk::binding(7, MODEL)]] StructuredBuffer<float4x4> _instanceBoneMatrices;
[[vk::binding(8, MODEL)]] StructuredBuffer<float4x4> _instanceTextureTransformMatrices;
[[vk::binding(9, MODEL)]] RWStructuredBuffer<PackedAnimatedVertexPosition> _animatedModelVertexPositions;
[[vk::binding(10, MODEL)]] StructuredBuffer<uint> _modelIndices;
[[vk::binding(11, MODEL)]] StructuredBuffer<ModelTextureUnit> _modelTextureUnits;
[[vk::binding(12, MODEL)]] SamplerState _samplers[MAX_MODEL_SAMPLERS];
Expand Down
11 changes: 6 additions & 5 deletions Source/Shaders/Shaders/Include/VisibilityBuffers.inc.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define VISIBILITYBUFFERS_INCLUDED

#include "DescriptorSet/Global.inc.slang"
#include "DescriptorSet/Model.inc.slang"

#include "Model/ModelShared.inc.slang"
#include "Terrain/TerrainShared.inc.slang"
Expand Down Expand Up @@ -423,22 +424,22 @@ PixelVertexData GetPixelVertexDataTerrain(const uint2 pixelPos, const Visibility

PixelVertexData GetPixelVertexDataModel(const uint2 pixelPos, const VisibilityBuffer vBuffer, const uint cameraIndex, float2 renderSize)
{
InstanceRef instanceRef = GetOpaqueModelInstanceID(vBuffer.instanceID);
InstanceRef instanceRef = _opaqueInstanceRefTable[vBuffer.instanceID];
uint instanceID = instanceRef.instanceID;
uint drawID = instanceRef.drawID;

ModelInstanceData instanceData = _modelInstanceDatas[instanceID];
IndexedDraw draw = _modelDraws[drawID];
IndexedDraw draw = _opaqueModelDraws[drawID];
uint3 vertexIDs = GetVertexIDs(vBuffer.triangleID, draw, _modelIndices);

ModelVertex vertices[3];
[unroll]
for (uint i = 0; i < 3; i++)
for (uint i = 0; i < 3; i++)
{
vertices[i] = LoadModelVertex(vertexIDs[i]);
vertices[i] = LoadModelVertex(_packedModelVertices, vertexIDs[i]);
if (instanceData.boneMatrixOffset != 4294967295)
{
float4x4 boneTransformMatrix = CalcBoneTransformMatrix(instanceData, vertices[i]);
float4x4 boneTransformMatrix = CalcBoneTransformMatrix(_instanceBoneMatrices, instanceData, vertices[i]);
vertices[i].position = mul(float4(vertices[i].position, 1.0f), boneTransformMatrix).xyz;
vertices[i].normal = mul(vertices[i].normal, (float3x3)boneTransformMatrix);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Shaders/Shaders/Material/MaterialPass.cs.slang
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ float4 ShadeModel(const uint2 pixelPos, const float2 screenUV, const VisibilityB
// Get the interpolated vertex data from the visibility buffer
PixelVertexData pixelVertexData = GetPixelVertexDataModel(pixelPos, vBuffer, 0, _constants.renderInfo.xy);

TextureData textureData = LoadModelTextureData(pixelVertexData.extraID);
TextureData textureData = LoadModelTextureData(_packedModelTextureDatas, pixelVertexData.extraID);

// Shade
float4 color = float4(0, 0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion Source/Shaders/Shaders/Model/Draw.ps.slang
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PSOutput main(PSInput input)
uint textureDataID = input.drawIDInstanceIDTextureDataIDInstanceRefID.z;
uint instanceRefID = input.drawIDInstanceIDTextureDataIDInstanceRefID.w;

TextureData textureData = LoadModelTextureData(textureDataID);
TextureData textureData = LoadModelTextureData(_packedModelTextureDatas, textureDataID);

for (uint textureUnitIndex = textureData.textureUnitOffset; textureUnitIndex < textureData.textureUnitOffset + textureData.numTextureUnits; textureUnitIndex++)
{
Expand Down
13 changes: 7 additions & 6 deletions Source/Shaders/Shaders/Model/Draw.vs.slang
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ permutation SHADOW_PASS = [0, 1];
#define GEOMETRY_PASS 1

#include "DescriptorSet/Global.inc.slang"
#include "DescriptorSet/Model.inc.slang"

#include "Include/Common.inc.slang"
#include "Model/ModelShared.inc.slang"
Expand Down Expand Up @@ -32,16 +33,16 @@ struct VSOutput
[shader("vertex")]
VSOutput main(VSInput input)
{
uint instanceRefID = GetOpaqueInstanceRefID(input.culledInstanceID);
InstanceRef instanceRef = GetOpaqueModelInstanceID(instanceRefID);
uint instanceRefID = _opaqueCulledInstanceLookupTable[input.culledInstanceID];
InstanceRef instanceRef = _opaqueInstanceRefTable[instanceRefID];
uint instanceID = instanceRef.instanceID;
uint drawID = instanceRef.drawID;

ModelInstanceData instanceData = _modelInstanceDatas[instanceID];

// Skin this vertex
ModelVertex vertex = LoadModelVertex(input.vertexID);
float4x4 boneTransformMatrix = CalcBoneTransformMatrix(instanceData, vertex);
ModelVertex vertex = LoadModelVertex(_packedModelVertices, input.vertexID);
float4x4 boneTransformMatrix = CalcBoneTransformMatrix(_instanceBoneMatrices, instanceData, vertex);
float4 position = mul(float4(vertex.position, 1.0f), boneTransformMatrix);

// Save the skinned vertex position (in model-space) if this vertex was animated
Expand All @@ -50,7 +51,7 @@ VSOutput main(VSInput input)
uint localVertexID = input.vertexID - instanceData.modelVertexOffset; // This gets the local vertex ID relative to the model
uint animatedVertexID = localVertexID + instanceData.animatedVertexOffset; // This makes it relative to the animated instance

StoreAnimatedVertexPosition(animatedVertexID, position.xyz);
StoreAnimatedVertexPosition(_animatedModelVertexPositions, animatedVertexID, position.xyz);
}

float4x4 instanceMatrix = _modelInstanceMatrices[instanceID];
Expand All @@ -67,7 +68,7 @@ VSOutput main(VSInput input)

if (instanceData.textureTransformMatrixOffset != 4294967295)
{
TextureData textureData = LoadModelTextureData(instanceRef.extraID);
TextureData textureData = LoadModelTextureData(_packedModelTextureDatas, instanceRef.extraID);
uint numTextureUnits = textureData.numTextureUnits;

if (numTextureUnits > 0)
Expand Down
3 changes: 2 additions & 1 deletion Source/Shaders/Shaders/Model/DrawSkybox.ps.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ permutation TRANSPARENCY = [0, 1];
#define GEOMETRY_PASS 1

#include "DescriptorSet/Global.inc.slang"
#include "DescriptorSet/Model.inc.slang"

#include "Include/Common.inc.slang"
#include "Include/OIT.inc.slang"
Expand All @@ -28,7 +29,7 @@ struct PSOutput
[shader("fragment")]
PSOutput main(PSInput input)
{
TextureData textureData = LoadModelTextureData(input.textureDataID);
TextureData textureData = LoadModelTextureData(_packedModelTextureDatas, input.textureDataID);

float4 color = float4(0, 0, 0, 0);

Expand Down
9 changes: 5 additions & 4 deletions Source/Shaders/Shaders/Model/DrawSkybox.vs.slang
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include "DescriptorSet/Global.inc.slang"
#include "DescriptorSet/Model.inc.slang"

#include "Include/Common.inc.slang"
#include "Model/ModelShared.inc.slang"
Expand Down Expand Up @@ -32,8 +33,8 @@ VSOutput main(VSInput input)
ModelInstanceData instanceData = _modelInstanceDatas[instanceID];

// Skin this vertex
ModelVertex vertex = LoadModelVertex(input.vertexID);
float4x4 boneTransformMatrix = CalcBoneTransformMatrix(instanceData, vertex);
ModelVertex vertex = LoadModelVertex(_packedModelVertices, input.vertexID);
float4x4 boneTransformMatrix = CalcBoneTransformMatrix(_instanceBoneMatrices, instanceData, vertex);
float4 position = mul(float4(vertex.position, 1.0f), boneTransformMatrix);

// Save the skinned vertex position (in model-space) if this vertex was animated
Expand All @@ -42,7 +43,7 @@ VSOutput main(VSInput input)
uint localVertexID = input.vertexID - instanceData.modelVertexOffset; // This gets the local vertex ID relative to the model
uint animatedVertexID = localVertexID + instanceData.animatedVertexOffset; // This makes it relative to the animated instance

StoreAnimatedVertexPosition(animatedVertexID, position.xyz);
StoreAnimatedVertexPosition(_animatedModelVertexPositions, animatedVertexID, position.xyz);
}

float4x4 instanceMatrix = _modelInstanceMatrices[instanceID];
Expand All @@ -52,7 +53,7 @@ VSOutput main(VSInput input)

if (instanceData.textureTransformMatrixOffset != 4294967295)
{
TextureData textureData = LoadModelTextureData(textureDataID);
TextureData textureData = LoadModelTextureData(_packedModelTextureDatas, textureDataID);
uint numTextureUnits = textureData.numTextureUnits;

if (numTextureUnits > 0)
Expand Down
4 changes: 3 additions & 1 deletion Source/Shaders/Shaders/Model/DrawTransparent.ps.slang
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

#define GEOMETRY_PASS 1
#define MAX_MODEL_SAMPLERS 4

#include "DescriptorSet/Global.inc.slang"
#include "DescriptorSet/Model.inc.slang"

#include "Include/Common.inc.slang"
#include "Include/OIT.inc.slang"
Expand All @@ -25,7 +27,7 @@ struct PSOutput
[shader("fragment")]
PSOutput main(PSInput input)
{
TextureData textureData = LoadModelTextureData(input.textureDataID);
TextureData textureData = LoadModelTextureData(_packedModelTextureDatas, input.textureDataID);

float4 color = float4(0, 0, 0, 0);

Expand Down
Loading
Loading