Added shader reflection to KRContext
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled

ShaderValue::absolute_time is now reflected by KRContext, eliminating the explicit setPushConstant call
This commit is contained in:
2026-06-01 23:30:58 -07:00
parent 447f2d730d
commit dcebdde968
4 changed files with 20 additions and 2 deletions

View File

@@ -914,3 +914,17 @@ KrResult KRContext::getMappedResource(KrResourceMapIndex resourceHandle, KRResou
}
return KR_SUCCESS;
}
bool KRContext::getShaderValue(const KRCamera* camera, ShaderValue value, float* output) const
{
switch (value)
{
case ShaderValue::absolute_time:
*output = getAbsoluteTime();
return true;
default:
break;
}
return KRReflectedObject::getShaderValue(camera, value, output);
}

View File

@@ -58,7 +58,7 @@ class KRUniformBufferManager;
class KRSurfaceManager;
class KRSamplerManager;
class KRContext
class KRContext : public KRReflectedObject
{
public:
static int KRENGINE_MAX_PIPELINE_HANDLES;
@@ -223,4 +223,6 @@ private:
std::unique_ptr<KRPresentationThread> m_presentationThread;
unordered_map<KrSurfaceMapIndex, KrSurfaceHandle> m_surfaceHandleMap;
virtual bool getShaderValue(const KRCamera* camera, ShaderValue value, float* output) const;
};

View File

@@ -628,6 +628,7 @@ void KRPipeline::setPushConstant(ShaderValue location, const Vector2& value)
}
}
}
void KRPipeline::setPushConstant(ShaderValue location, const Vector3& value)
{
for (StageInfo& stageInfo : m_stages) {
@@ -681,7 +682,6 @@ bool KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM
if (!setPushConstants(ri.camera, ri.reflectedObjects)) {
return false;
}
setPushConstant(ShaderValue::absolute_time, getContext().getAbsoluteTime());
for (StageInfo& stageInfo : m_stages) {
PushConstantInfo& pushConstants = stageInfo.pushConstants;

View File

@@ -161,6 +161,7 @@ KRRenderPass* KRRenderGraph::getFinalRenderPass()
void KRRenderGraph::render(VkCommandBuffer &commandBuffer, KRSurface& surface, KRCamera* camera)
{
KRNode::RenderInfo ri(commandBuffer);
ri.reflectedObjects.push_back(&getContext());
ri.camera = camera;
if (camera) {
ri.viewport = camera->getViewport();
@@ -177,6 +178,7 @@ void KRRenderGraph::render(VkCommandBuffer &commandBuffer, KRSurface& surface, K
}
pass->end(commandBuffer);
}
ri.reflectedObjects.pop_back();
}
void KRRenderGraph::destroy(KRDevice& device)