From f611990b10538a0fd778be485ec9e30792efa4e2 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Mon, 5 Feb 2018 12:00:54 -0800 Subject: [PATCH] Fix overlimit shader char strings --- libraries/render-utils/src/DeferredLightingEffect.cpp | 10 +++++----- tests/shaders/src/main.cpp | 2 +- tools/scribe/src/main.cpp | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index d0d9708c04..7aefb9c13c 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -83,7 +83,7 @@ enum DeferredShader_BufferSlot { LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, }; -static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations); +static void loadLightProgram(const std::string& vertSource, const std::string& fragSource, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations); void DeferredLightingEffect::init() { _directionalAmbientSphereLightLocations = std::make_shared(); @@ -171,9 +171,9 @@ void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch, int cluste } } -static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* fragSource, LightLocationsPtr& locations) { - auto VS = gpu::Shader::createVertex(std::string(vertSource)); - auto PS = gpu::Shader::createPixel(std::string(fragSource)); +static gpu::ShaderPointer makeLightProgram(const std::string& vertSource, const std::string& fragSource, LightLocationsPtr& locations) { + auto VS = gpu::Shader::createVertex(vertSource); + auto PS = gpu::Shader::createPixel(fragSource); gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS); @@ -224,7 +224,7 @@ static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* f return program; } -static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) { +static void loadLightProgram(const std::string& vertSource, const std::string& fragSource, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) { gpu::ShaderPointer program = makeLightProgram(vertSource, fragSource, locations); diff --git a/tests/shaders/src/main.cpp b/tests/shaders/src/main.cpp index 3f48e37a76..b1a969fcc8 100644 --- a/tests/shaders/src/main.cpp +++ b/tests/shaders/src/main.cpp @@ -135,7 +135,7 @@ const std::string PIXEL_SHADER_DEFINES{ R"GLSL( #define GPU_TRANSFORM_STEREO_SPLIT_SCREEN )GLSL" }; -void testShaderBuild(const char* vs_src, const char * fs_src) { +void testShaderBuild(const std::string& vs_src, const std::string& fs_src) { std::string error; std::vector binary; GLuint vs, fs; diff --git a/tools/scribe/src/main.cpp b/tools/scribe/src/main.cpp index 810f6c0f45..4f58ada303 100755 --- a/tools/scribe/src/main.cpp +++ b/tools/scribe/src/main.cpp @@ -211,12 +211,13 @@ int main (int argc, char** argv) { targetStringStream << "// File generated by Scribe " << vars["_SCRIBE_DATE"] << std::endl; targetStringStream << "#ifndef scribe_" << targetName << "_h" << std::endl; targetStringStream << "#define scribe_" << targetName << "_h" << std::endl << std::endl; + targetStringStream << "#include " << std::endl << std::endl; - targetStringStream << "const char " << targetName << "[] = \n"; + targetStringStream << "static std::string " << targetName << " = std::string()\n"; // Write the pages content for (auto page : pages) { - targetStringStream << "R\"SCRIBE(\n" << page->str() << "\n)SCRIBE\"\n"; + targetStringStream << "+ std::string(R\"SCRIBE(\n" << page->str() << "\n)SCRIBE\")\n"; } targetStringStream << ";\n" << std::endl << std::endl;