From d2da0d607885c9a8e548f6db4be91aa9b23f6247 Mon Sep 17 00:00:00 2001 From: halx99 Date: Thu, 20 Oct 2022 20:22:28 +0800 Subject: [PATCH] Validate shared VertexLayout from Shader Program --- core/2d/CCDrawNode.cpp | 7 +++++++ core/2d/CCDrawNode.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/core/2d/CCDrawNode.cpp b/core/2d/CCDrawNode.cpp index 243ec25311..d62ea3e8a7 100644 --- a/core/2d/CCDrawNode.cpp +++ b/core/2d/CCDrawNode.cpp @@ -170,10 +170,17 @@ void DrawNode::updateShaderInternal(CustomCommand& cmd, auto program = backend::Program::getBuiltinProgram(programType); pipelinePS = new backend::ProgramState(program); + setVertexLayout(cmd); cmd.setPrimitiveType(primitiveType); cmd.setDrawType(drawType); } +void DrawNode::setVertexLayout(CustomCommand& cmd) +{ + auto* programState = cmd.getPipelineDescriptor().programState; + programState->validateSharedVertexLayout(VertexLayoutHelper::setupDrawNode); +} + void DrawNode::freeShaderInternal(CustomCommand& cmd) { auto& pipelinePS = cmd.getPipelineDescriptor().programState; diff --git a/core/2d/CCDrawNode.h b/core/2d/CCDrawNode.h index 1826cc206c..89efdc581d 100644 --- a/core/2d/CCDrawNode.h +++ b/core/2d/CCDrawNode.h @@ -378,6 +378,8 @@ protected: CustomCommand::PrimitiveType primitiveType); void freeShaderInternal(CustomCommand& cmd); + void setVertexLayout(CustomCommand& cmd); + void updateBlendState(CustomCommand& cmd); void updateUniforms(const Mat4& transform, CustomCommand& cmd);