Skip to content

Commit

Permalink
Fixes for validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Duttenheim committed Nov 22, 2024
1 parent 06f57a0 commit b8032ca
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 63 deletions.
31 changes: 11 additions & 20 deletions code/render/coregraphics/vk/vkshader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ ShaderSetup(
cbo.num = binding.descriptorCount;
cbo.visibility = AllVisibility;
uint32_t slotsUsed = 0;
if (block->HasAnnotation("Visibility"))
{
cbo.visibility = ShaderVisibilityFromString(block->GetAnnotationString("Visibility").c_str());
}

if (binding.binding != 0xFFFFFFFF)
{
Expand All @@ -131,16 +135,7 @@ ShaderSetup(

if (occupiesNewBinding)
{
if (block->HasAnnotation("Visibility"))
{
cbo.visibility = ShaderVisibilityFromString(block->GetAnnotationString("Visibility").c_str());
UpdateOccupancy(numPerStageUniformBuffers, slotsUsed, cbo.visibility);
}
else
{
for (IndexT i = 0; i < NumShaders; i++)
numPerStageUniformBuffers[i]++;
}
UpdateOccupancy(numPerStageUniformBuffers, slotsUsed, cbo.visibility);
}
}

Expand Down Expand Up @@ -213,21 +208,17 @@ ShaderSetup(
ResourceTableLayoutCreateInfo& rinfo = layoutCreateInfos.Emplace(buffer->set);
numsets = Math::max(numsets, buffer->set + 1);

if (buffer->HasAnnotation("Visibility"))
{
rwbo.visibility = ShaderVisibilityFromString(buffer->GetAnnotationString("Visibility").c_str());
}

bool occupiesNewBinding = !bindingTable[binding.binding];
bindingTable[binding.binding] = true;

if (occupiesNewBinding)
{
if (buffer->HasAnnotation("Visibility"))
{
rwbo.visibility = ShaderVisibilityFromString(buffer->GetAnnotationString("Visibility").c_str());
UpdateOccupancy(numPerStageStorageBuffers, slotsUsed, rwbo.visibility);
}
else
{
for (IndexT i = 0; i < NumShaders; i++)
numPerStageStorageBuffers[i]++;
}
UpdateOccupancy(numPerStageStorageBuffers, slotsUsed, rwbo.visibility);
}

if (buffer->set == NEBULA_DYNAMIC_OFFSET_GROUP || buffer->set == NEBULA_INSTANCE_GROUP)
Expand Down
8 changes: 5 additions & 3 deletions code/render/coregraphics/vk/vktypes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ VkTypes::AsVkSampleFlags(const SizeT samples)
//------------------------------------------------------------------------------
/**
*/
VkImageType
VkImageType
VkTypes::AsVkImageType(CoreGraphics::TextureType type)
{
switch (type)
Expand Down Expand Up @@ -340,7 +340,7 @@ VkTypes::AsVkImageType(CoreGraphics::TextureType type)
//------------------------------------------------------------------------------
/**
*/
VkImageViewType
VkImageViewType
VkTypes::AsVkImageViewType(CoreGraphics::TextureType type)
{
switch (type)
Expand Down Expand Up @@ -371,7 +371,7 @@ VkTypes::AsVkImageViewType(CoreGraphics::TextureType type)
CoreGraphics::PixelFormat::Code
VkTypes::AsNebulaPixelFormat(VkFormat f)
{

switch (f)
{
case VK_FORMAT_R8G8B8A8_UINT: return PixelFormat::R8G8B8A8;
Expand Down Expand Up @@ -469,6 +469,8 @@ VkShaderStageFlags
VkTypes::AsVkShaderVisibility(const CoreGraphics::ShaderVisibility vis)
{
VkShaderStageFlags ret = 0;
if (vis == AllVisibility) return VK_SHADER_STAGE_ALL;
else if (vis == AllGraphicsVisibility) return VK_SHADER_STAGE_ALL_GRAPHICS;
if (AllBits(vis, VertexShaderVisibility)) ret |= VK_SHADER_STAGE_VERTEX_BIT;
if (AllBits(vis, HullShaderVisibility)) ret |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
if (AllBits(vis, DomainShaderVisibility)) ret |= VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
Expand Down
24 changes: 0 additions & 24 deletions code/render/frame/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,18 +418,6 @@
{
"name": "SunShadowDepth",
"stage": "PixelShaderRead"
},
{
"name": "ClusterLightIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterFogIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterDecalIndexLists",
"stage": "PixelShaderRead"
}
],

Expand Down Expand Up @@ -481,18 +469,6 @@
{
"name": "SunShadowDepth",
"stage": "PixelShaderRead"
},
{
"name": "ClusterLightIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterFogIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterDecalIndexLists",
"stage": "PixelShaderRead"
}
],

Expand Down
17 changes: 8 additions & 9 deletions code/render/models/modelcontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ ModelContext::Create()
void
ModelContext::Setup(const Graphics::GraphicsEntityId gfxId, const Resources::ResourceName& name, const Util::StringAtom& tag, std::function<void()> finishedCallback)
{
const ContextEntityId cid = GetContextId(gfxId);

auto successCallback = [cid, finishedCallback](Resources::ResourceId mid)
auto successCallback = [gfxId, finishedCallback](Resources::ResourceId mid)
{
// Go through model nodes and setup instance data
const Util::Array<Models::ModelNode*>& nodes = Models::ModelGetNodes(mid);
const ContextEntityId cid = GetContextId(gfxId);

// Run through nodes and collect transform and renderable nodes
NodeInstanceRange& transformRange = modelContextAllocator.Get<Model_NodeInstanceTransform>(cid.id);
Expand Down Expand Up @@ -124,7 +123,7 @@ ModelContext::Setup(const Graphics::GraphicsEntityId gfxId, const Resources::Res
NodeInstances.transformable.origTransforms.Extend(transformRange.end);
NodeInstances.transformable.nodeTransforms.Extend(transformRange.end);
}

for (SizeT i = 0; i < transformNodes.Size(); i++)
{
const uint index = transformRange.allocation.offset + i;
Expand Down Expand Up @@ -348,7 +347,7 @@ ModelContext::ChangeModel(const Graphics::GraphicsEntityId gfxId, const Resource
{
modelContextAllocator.Get<Model_Id>(cid.id) = mid;
const Math::mat4& pending = modelContextAllocator.Get<Model_Transform>(cid.id);

if (finishedCallback != nullptr)
setupCompleteQueue.Enqueue(finishedCallback);
};
Expand All @@ -360,7 +359,7 @@ ModelContext::ChangeModel(const Graphics::GraphicsEntityId gfxId, const Resource
//------------------------------------------------------------------------------
/**
*/
const Models::ModelId
const Models::ModelId
ModelContext::GetModel(const Graphics::GraphicsEntityId id)
{
const ContextEntityId cid = GetContextId(id);
Expand All @@ -370,7 +369,7 @@ ModelContext::GetModel(const Graphics::GraphicsEntityId id)
//------------------------------------------------------------------------------
/**
*/
const Models::ModelId
const Models::ModelId
ModelContext::GetModel(const Graphics::ContextEntityId id)
{
return modelContextAllocator.Get<Model_Id>(id.id);
Expand Down Expand Up @@ -518,7 +517,7 @@ ModelContext::SetAlwaysVisible(const Graphics::GraphicsEntityId id)
for (IndexT i = nodes.begin; i < nodes.end; i++)
{
NodeInstances.renderable.nodeFlags[i] = SetBits(NodeInstances.renderable.nodeFlags[i], NodeInstanceFlags::NodeInstance_AlwaysVisible);
}
}
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -807,7 +806,7 @@ ModelContext::WaitForWork(const Graphics::FrameContext& ctx)
void
ModelContext::OnRenderDebug(uint32_t flags)
{
//const Util::Array<ModelInstanceId>& instances = modelContextAllocator.GetArray<Model_InstanceId>();
//const Util::Array<ModelInstanceId>& instances = modelContextAllocator.GetArray<Model_InstanceId>();
//Util::Array<Math::bbox>& instanceBoxes = Models::modelPool->modelInstanceAllocator.GetArray<StreamModelCache::InstanceBoundingBox>();
//const Util::Array<Math::mat4>& transforms = Models::modelPool->modelInstanceAllocator.GetArray<StreamModelCache::InstanceTransform>();
//const Util::Array<Math::bbox>& modelBoxes = Models::modelPool->modelAllocator.GetArray<Model_Id>();
Expand Down
17 changes: 10 additions & 7 deletions fips-files/generators/framescriptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,12 @@ def __init__(self, parser, node):
Error(self.name, "Texture source must define image bits")

self.destTex = dest['tex']
self.destBits = dest['bits']
self.destBits = dest['bits']

self.resourceDependencies = [
ResourceDependencyDefinition.raw(name = self.sourceTex, stage = "TransferRead", parser = parser),
ResourceDependencyDefinition.raw(name = self.destTex, stage = "TransferWrite", parser = parser)
]

def FormatHeader(self, file):
file.WriteLine("void Copy_{}(const CoreGraphics::CmdBufferId cmdBuf);".format(self.name))
Expand All @@ -500,6 +505,8 @@ def FormatExtern(self, file, parser):
file.WriteLine("//------------------------------------------------------------------------------")
file.WriteLine("/**")
file.WriteLine("*/")
DeclareResourceDependencies("Copy_{}".format(self.name), parser, self.resourceDependencies, file)
file.WriteLine("")
file.WriteLine("void")
file.WriteLine("Copy_{}(const CoreGraphics::CmdBufferId cmdBuf)".format(self.name))
file.WriteLine("{")
Expand All @@ -513,6 +520,7 @@ def FormatExtern(self, file, parser):
file.WriteLine("}")

def FormatSource(self, file):
SyncResourceDependencies("Copy_{}".format(self.name), self.resourceDependencies, file)
file.WriteLine("Copy_{}(cmdBuf);".format(self.name))

def FormatSetup(self, file):
Expand Down Expand Up @@ -566,13 +574,8 @@ def FormatExtern(self, file, parser):
file.WriteLine("//------------------------------------------------------------------------------")
file.WriteLine("/**")
file.WriteLine("*/")

DeclareResourceDependencies("Blit_{}".format(self.name), parser, self.resourceDependencies, file)

file.WriteLine("")
file.WriteLine("//------------------------------------------------------------------------------")
file.WriteLine("/**")
file.WriteLine("*/")
file.WriteLine("void")
file.WriteLine("Blit_{}(const CoreGraphics::CmdBufferId cmdBuf)".format(self.name))
file.WriteLine("{")
Expand Down Expand Up @@ -670,7 +673,7 @@ def FormatExtern(self, file, parser):
file.WriteLine("/**")
file.WriteLine("*/")

DeclareResourceDependencies("Swap_{}".format(self.name), parser, self.resourceDependencies, file)
DeclareResourceDependencies("Swap_{}".format(self.name), parser, self.resourceDependencies, file)

def FormatSource(self, file):
file.WriteLine('CoreGraphics::QueueBeginMarker(CoreGraphics::GraphicsQueueType, NEBULA_MARKER_GRAPHICS, "Swap");')
Expand Down

0 comments on commit b8032ca

Please sign in to comment.