Merge pull request #12340 from jherico/fix/shader_length

Fix overlimit shader char strings
This commit is contained in:
Sam Gateau 2018-02-09 09:31:15 -08:00 committed by GitHub
commit 047d24fe5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 416 additions and 316 deletions

View file

@ -13,6 +13,11 @@ include("cmake/init.cmake")
include("cmake/compiler.cmake") include("cmake/compiler.cmake")
if (BUILD_SCRIBE_ONLY)
add_subdirectory(tools/scribe)
return()
endif()
if (NOT DEFINED SERVER_ONLY) if (NOT DEFINED SERVER_ONLY)
set(SERVER_ONLY 0) set(SERVER_ONLY 0)
endif() endif()

View file

@ -18,7 +18,7 @@ android {
'-DANDROID_TOOLCHAIN=clang', '-DANDROID_TOOLCHAIN=clang',
'-DANDROID_STL=c++_shared', '-DANDROID_STL=c++_shared',
'-DQT_CMAKE_PREFIX_PATH=' + HIFI_ANDROID_PRECOMPILED + '/qt/lib/cmake', '-DQT_CMAKE_PREFIX_PATH=' + HIFI_ANDROID_PRECOMPILED + '/qt/lib/cmake',
'-DNATIVE_SCRIBE=' + HIFI_ANDROID_PRECOMPILED + '/scribe', '-DNATIVE_SCRIBE=' + HIFI_ANDROID_PRECOMPILED + '/scribe' + EXEC_SUFFIX,
'-DHIFI_ANDROID_PRECOMPILED=' + HIFI_ANDROID_PRECOMPILED, '-DHIFI_ANDROID_PRECOMPILED=' + HIFI_ANDROID_PRECOMPILED,
'-DRELEASE_NUMBER=' + RELEASE_NUMBER, '-DRELEASE_NUMBER=' + RELEASE_NUMBER,
'-DRELEASE_TYPE=' + RELEASE_TYPE, '-DRELEASE_TYPE=' + RELEASE_TYPE,

View file

@ -137,16 +137,16 @@ def packages = [
def scribeLocalFile='scribe' + EXEC_SUFFIX def scribeLocalFile='scribe' + EXEC_SUFFIX
def scribeFile='scribe_linux_x86_64' def scribeFile='scribe_linux_x86_64'
def scribeChecksum='c98678d9726bd8bbf1bab792acf3ff6c' def scribeChecksum='ca4b904f52f4f993c29175ba96798fa6'
def scribeVersion='onfeBkJWcJiTwiGOyZPVBjlyhoYQ4Axn' def scribeVersion='wgpf4dB2Ltzg4Lb2jJ4nPFsHoDkmK_OO'
if (Os.isFamily(Os.FAMILY_MAC)) { if (Os.isFamily(Os.FAMILY_MAC)) {
scribeFile = 'scribe_osx_x86_64' scribeFile = 'scribe_osx_x86_64'
scribeChecksum='a137ad62c1bf7cca739da219544a9a16' scribeChecksum='72db9d32d4e1e50add755570ac5eb749'
scribeVersion='kU.Aq512HVe65uRnkFEWQEqeQfaYF2c0' scribeVersion='o_NbPrktzEYtBkQf3Tn7zc1nZWzM52w6'
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) { } else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
scribeFile = 'scribe_win32_x86_64.exe' scribeFile = 'scribe_win32_x86_64.exe'
scribeChecksum='75c2ce9ed45d17de375e3988bfaba816' scribeChecksum='678e43d290c90fda670c6fefe038a06d'
scribeVersion='24TfWFh1FBY.t6i_LdzAXZYeQOtmQNZp' scribeVersion='GCCJxlmd2irvNOFWfZR0U1UCLHndHQrC'
} }
def options = [ def options = [

View file

@ -39,56 +39,41 @@ function(AUTOSCRIBE_SHADER SHADER_FILE)
get_filename_component(SHADER_TARGET ${SHADER_FILE} NAME_WE) get_filename_component(SHADER_TARGET ${SHADER_FILE} NAME_WE)
get_filename_component(SHADER_EXT ${SHADER_FILE} EXT) get_filename_component(SHADER_EXT ${SHADER_FILE} EXT)
if(SHADER_EXT STREQUAL .slv) if(SHADER_EXT STREQUAL .slv)
set(SHADER_TARGET ${SHADER_TARGET}_vert.h) set(SHADER_TYPE vert)
elseif(${SHADER_EXT} STREQUAL .slf) elseif(${SHADER_EXT} STREQUAL .slf)
set(SHADER_TARGET ${SHADER_TARGET}_frag.h) set(SHADER_TYPE frag)
elseif(${SHADER_EXT} STREQUAL .slg) elseif(${SHADER_EXT} STREQUAL .slg)
set(SHADER_TARGET ${SHADER_TARGET}_geom.h) set(SHADER_TYPE geom)
endif() endif()
set(SHADER_TARGET ${SHADER_TARGET}_${SHADER_TYPE})
set(SHADER_TARGET "${SHADERS_DIR}/${SHADER_TARGET}") set(SHADER_TARGET "${SHADERS_DIR}/${SHADER_TARGET}")
set(SHADER_TARGET_HEADER ${SHADER_TARGET}.h)
set(SHADER_TARGET_SOURCE ${SHADER_TARGET}.cpp)
set(SCRIBE_COMMAND scribe)
# Target dependant Custom rule on the SHADER_FILE # Target dependant Custom rule on the SHADER_FILE
if (APPLE) if (APPLE)
set(GLPROFILE MAC_GL) set(GLPROFILE MAC_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND scribe ${SCRIBE_ARGS} DEPENDS scribe ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
elseif (ANDROID) elseif (ANDROID)
set(GLPROFILE LINUX_GL) set(GLPROFILE LINUX_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE}) set(SCRIBE_COMMAND ${NATIVE_SCRIBE})
# for an android build, we can't use the scribe that cmake would normally produce as a target,
# since it's unrunnable by the cross-compiling build machine
# so, we require the compiling user to point us at a compiled executable version for their native toolchain
if (NOT NATIVE_SCRIBE)
find_program(NATIVE_SCRIBE scribe PATHS ${SCRIBE_PATH} ENV SCRIBE_PATH)
endif()
if (NOT NATIVE_SCRIBE)
message(FATAL_ERROR "The High Fidelity scribe tool is required for shader pre-processing. \
Please compile scribe using your native toolchain and set SCRIBE_PATH to the path containing the scribe executable in your ENV.\
")
endif ()
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND ${NATIVE_SCRIBE} ${SCRIBE_ARGS} DEPENDS ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
elseif (UNIX) elseif (UNIX)
set(GLPROFILE LINUX_GL) set(GLPROFILE LINUX_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND scribe ${SCRIBE_ARGS} DEPENDS scribe ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
else () else ()
set(GLPROFILE PC_GL) set(GLPROFILE PC_GL)
set(SCRIBE_ARGS -c++ -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(OUTPUT ${SHADER_TARGET} COMMAND scribe ${SCRIBE_ARGS} DEPENDS scribe ${SHADER_INCLUDE_FILES} ${SHADER_FILE})
endif() endif()
set(SCRIBE_ARGS -c++ -T ${SHADER_TYPE} -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
add_custom_command(
OUTPUT ${SHADER_TARGET_HEADER} ${SHADER_TARGET_SOURCE}
COMMAND ${SCRIBE_COMMAND} ${SCRIBE_ARGS}
DEPENDS ${SCRIBE_COMMAND} ${SHADER_INCLUDE_FILES} ${SHADER_FILE}
)
#output the generated file name #output the generated file name
set(AUTOSCRIBE_SHADER_RETURN ${SHADER_TARGET} PARENT_SCOPE) set(AUTOSCRIBE_SHADER_RETURN ${SHADER_TARGET_HEADER} ${SHADER_TARGET_SOURCE} PARENT_SCOPE)
file(GLOB INCLUDE_FILES ${SHADER_TARGET}) file(GLOB INCLUDE_FILES ${SHADER_TARGET_HEADER})
endfunction() endfunction()
@ -126,7 +111,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
if (WIN32) if (WIN32)
source_group("Shaders" FILES ${SHADER_INCLUDE_FILES}) source_group("Shaders" FILES ${SHADER_INCLUDE_FILES})
source_group("Shaders" FILES ${SHADER_SOURCE_FILES}) source_group("Shaders" FILES ${SHADER_SOURCE_FILES})
source_group("Shaders" FILES ${AUTOSCRIBE_SHADER_SRC}) source_group("Shaders\\generated" FILES ${AUTOSCRIBE_SHADER_SRC})
endif() endif()
list(APPEND AUTOSCRIBE_SHADER_LIB_SRC ${SHADER_INCLUDE_FILES}) list(APPEND AUTOSCRIBE_SHADER_LIB_SRC ${SHADER_INCLUDE_FILES})
@ -136,4 +121,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
# Link library shaders, if they exist # Link library shaders, if they exist
include_directories("${SHADERS_DIR}") include_directories("${SHADERS_DIR}")
# Add search directory to find gpu/Shader.h
include_directories("${HIFI_LIBRARY_DIR}/gpu/src")
endmacro() endmacro()

View file

@ -395,8 +395,8 @@ void HmdDisplayPlugin::HUDRenderer::build() {
void HmdDisplayPlugin::HUDRenderer::updatePipeline() { void HmdDisplayPlugin::HUDRenderer::updatePipeline() {
if (!pipeline) { if (!pipeline) {
auto vs = gpu::Shader::createVertex(std::string(hmd_ui_vert)); auto vs = hmd_ui_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(hmd_ui_frag)); auto ps = hmd_ui_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps); auto program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram(*program, gpu::Shader::BindingSet()); gpu::Shader::makeProgram(*program, gpu::Shader::BindingSet());
uniformsLocation = program->getUniformBuffers().findLocation("hudBuffer"); uniformsLocation = program->getUniformBuffers().findLocation("hudBuffer");

View file

@ -36,8 +36,8 @@ static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, co
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
PrepareStencil::testMask(*state); PrepareStencil::testMask(*state);
auto vertShader = gpu::Shader::createVertex(std::string(textured_particle_vert)); auto vertShader = textured_particle_vert::getShader();
auto fragShader = gpu::Shader::createPixel(std::string(textured_particle_frag)); auto fragShader = textured_particle_frag::getShader();
auto program = gpu::Shader::createProgram(vertShader, fragShader); auto program = gpu::Shader::createProgram(vertShader, fragShader);
_texturedPipeline = texturedPipeline = gpu::Pipeline::create(program, state); _texturedPipeline = texturedPipeline = gpu::Pipeline::create(program, state);

View file

@ -48,8 +48,8 @@ struct PolyLineUniforms {
static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) { static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) {
if (!polylinePipeline) { if (!polylinePipeline) {
auto VS = gpu::Shader::createVertex(std::string(paintStroke_vert)); auto VS = paintStroke_vert::getShader();
auto PS = gpu::Shader::createPixel(std::string(paintStroke_frag)); auto PS = paintStroke_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS); gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
#ifdef POLYLINE_ENTITY_USE_FADE_EFFECT #ifdef POLYLINE_ENTITY_USE_FADE_EFFECT
auto fadeVS = gpu::Shader::createVertex(std::string(paintStroke_fade_vert)); auto fadeVS = gpu::Shader::createVertex(std::string(paintStroke_fade_vert));

View file

@ -27,6 +27,7 @@
#include <StencilMaskPass.h> #include <StencilMaskPass.h>
#include "EntityTreeRenderer.h" #include "EntityTreeRenderer.h"
#include "polyvox_vert.h" #include "polyvox_vert.h"
#include "polyvox_frag.h" #include "polyvox_frag.h"
#include "polyvox_fade_vert.h" #include "polyvox_fade_vert.h"
@ -70,6 +71,7 @@
#include "StencilMaskPass.h" #include "StencilMaskPass.h"
#include "EntityTreeRenderer.h" #include "EntityTreeRenderer.h"
#include "polyvox_vert.h" #include "polyvox_vert.h"
#include "polyvox_frag.h" #include "polyvox_frag.h"
#include "polyvox_fade_vert.h" #include "polyvox_fade_vert.h"
@ -1459,8 +1461,8 @@ static gpu::Stream::FormatPointer _vertexFormat;
ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) {
if (!_pipelines[0]) { if (!_pipelines[0]) {
gpu::ShaderPointer vertexShaders[2] = { gpu::Shader::createVertex(std::string(polyvox_vert)), gpu::Shader::createVertex(std::string(polyvox_fade_vert)) }; gpu::ShaderPointer vertexShaders[2] = { polyvox_vert::getShader(), polyvox_fade_vert::getShader() };
gpu::ShaderPointer pixelShaders[2] = { gpu::Shader::createPixel(std::string(polyvox_frag)), gpu::Shader::createPixel(std::string(polyvox_fade_frag)) }; gpu::ShaderPointer pixelShaders[2] = { polyvox_frag::getShader(), polyvox_fade_frag::getShader() };
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), MATERIAL_GPU_SLOT)); slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), MATERIAL_GPU_SLOT));

View file

@ -16,8 +16,8 @@
#include <GeometryCache.h> #include <GeometryCache.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <render-utils/simple_vert.h> #include "render-utils/simple_vert.h"
#include <render-utils/simple_frag.h> #include "render-utils/simple_frag.h"
//#define SHAPE_ENTITY_USE_FADE_EFFECT //#define SHAPE_ENTITY_USE_FADE_EFFECT
#ifdef SHAPE_ENTITY_USE_FADE_EFFECT #ifdef SHAPE_ENTITY_USE_FADE_EFFECT
@ -32,8 +32,8 @@ static const float SPHERE_ENTITY_SCALE = 0.5f;
ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Parent(entity) { ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
_procedural._vertexSource = simple_vert; _procedural._vertexSource = simple_vert::getSource();
_procedural._fragmentSource = simple_frag; _procedural._fragmentSource = simple_frag::getSource();
_procedural._opaqueState->setCullMode(gpu::State::CULL_NONE); _procedural._opaqueState->setCullMode(gpu::State::CULL_NONE);
_procedural._opaqueState->setDepthTest(true, true, gpu::LESS_EQUAL); _procedural._opaqueState->setDepthTest(true, true, gpu::LESS_EQUAL);
PrepareStencil::testMaskDrawShape(*_procedural._opaqueState); PrepareStencil::testMaskDrawShape(*_procedural._opaqueState);

View file

@ -73,42 +73,42 @@ ShaderPointer StandardShaderLib::getProgram(GetShader getVS, GetShader getPS) {
ShaderPointer StandardShaderLib::getDrawUnitQuadTexcoordVS() { ShaderPointer StandardShaderLib::getDrawUnitQuadTexcoordVS() {
if (!_drawUnitQuadTexcoordVS) { if (!_drawUnitQuadTexcoordVS) {
_drawUnitQuadTexcoordVS = gpu::Shader::createVertex(std::string(DrawUnitQuadTexcoord_vert)); _drawUnitQuadTexcoordVS = DrawUnitQuadTexcoord_vert::getShader();
} }
return _drawUnitQuadTexcoordVS; return _drawUnitQuadTexcoordVS;
} }
ShaderPointer StandardShaderLib::getDrawTransformUnitQuadVS() { ShaderPointer StandardShaderLib::getDrawTransformUnitQuadVS() {
if (!_drawTransformUnitQuadVS) { if (!_drawTransformUnitQuadVS) {
_drawTransformUnitQuadVS = gpu::Shader::createVertex(std::string(DrawTransformUnitQuad_vert)); _drawTransformUnitQuadVS = DrawTransformUnitQuad_vert::getShader();
} }
return _drawTransformUnitQuadVS; return _drawTransformUnitQuadVS;
} }
ShaderPointer StandardShaderLib::getDrawTexcoordRectTransformUnitQuadVS() { ShaderPointer StandardShaderLib::getDrawTexcoordRectTransformUnitQuadVS() {
if (!_drawTexcoordRectTransformUnitQuadVS) { if (!_drawTexcoordRectTransformUnitQuadVS) {
_drawTexcoordRectTransformUnitQuadVS = gpu::Shader::createVertex(std::string(DrawTexcoordRectTransformUnitQuad_vert)); _drawTexcoordRectTransformUnitQuadVS = DrawTexcoordRectTransformUnitQuad_vert::getShader();
} }
return _drawTexcoordRectTransformUnitQuadVS; return _drawTexcoordRectTransformUnitQuadVS;
} }
ShaderPointer StandardShaderLib::getDrawViewportQuadTransformTexcoordVS() { ShaderPointer StandardShaderLib::getDrawViewportQuadTransformTexcoordVS() {
if (!_drawViewportQuadTransformTexcoordVS) { if (!_drawViewportQuadTransformTexcoordVS) {
_drawViewportQuadTransformTexcoordVS = gpu::Shader::createVertex(std::string(DrawViewportQuadTransformTexcoord_vert)); _drawViewportQuadTransformTexcoordVS = DrawViewportQuadTransformTexcoord_vert::getShader();
} }
return _drawViewportQuadTransformTexcoordVS; return _drawViewportQuadTransformTexcoordVS;
} }
ShaderPointer StandardShaderLib::getDrawVertexPositionVS() { ShaderPointer StandardShaderLib::getDrawVertexPositionVS() {
if (!_drawVertexPositionVS) { if (!_drawVertexPositionVS) {
_drawVertexPositionVS = gpu::Shader::createVertex(std::string(DrawVertexPosition_vert)); _drawVertexPositionVS = DrawVertexPosition_vert::getShader();
} }
return _drawVertexPositionVS; return _drawVertexPositionVS;
} }
ShaderPointer StandardShaderLib::getDrawTransformVertexPositionVS() { ShaderPointer StandardShaderLib::getDrawTransformVertexPositionVS() {
if (!_drawTransformVertexPositionVS) { if (!_drawTransformVertexPositionVS) {
_drawTransformVertexPositionVS = gpu::Shader::createVertex(std::string(DrawTransformVertexPosition_vert)); _drawTransformVertexPositionVS = DrawTransformVertexPosition_vert::getShader();
} }
return _drawTransformVertexPositionVS; return _drawTransformVertexPositionVS;
} }
@ -122,42 +122,42 @@ ShaderPointer StandardShaderLib::getDrawNadaPS() {
ShaderPointer StandardShaderLib::getDrawWhitePS() { ShaderPointer StandardShaderLib::getDrawWhitePS() {
if (!_drawWhitePS) { if (!_drawWhitePS) {
_drawWhitePS = gpu::Shader::createPixel(std::string(DrawWhite_frag)); _drawWhitePS = DrawWhite_frag::getShader();
} }
return _drawWhitePS; return _drawWhitePS;
} }
ShaderPointer StandardShaderLib::getDrawColorPS() { ShaderPointer StandardShaderLib::getDrawColorPS() {
if (!_drawColorPS) { if (!_drawColorPS) {
_drawColorPS = gpu::Shader::createPixel(std::string(DrawColor_frag)); _drawColorPS = DrawColor_frag::getShader();
} }
return _drawColorPS; return _drawColorPS;
} }
ShaderPointer StandardShaderLib::getDrawTexturePS() { ShaderPointer StandardShaderLib::getDrawTexturePS() {
if (!_drawTexturePS) { if (!_drawTexturePS) {
_drawTexturePS = gpu::Shader::createPixel(std::string(DrawTexture_frag)); _drawTexturePS = DrawTexture_frag::getShader();
} }
return _drawTexturePS; return _drawTexturePS;
} }
ShaderPointer StandardShaderLib::getDrawTextureMirroredXPS() { ShaderPointer StandardShaderLib::getDrawTextureMirroredXPS() {
if (!_drawTextureMirroredXPS) { if (!_drawTextureMirroredXPS) {
_drawTextureMirroredXPS = gpu::Shader::createPixel(std::string(DrawTextureMirroredX_frag)); _drawTextureMirroredXPS = DrawTextureMirroredX_frag::getShader();
} }
return _drawTextureMirroredXPS; return _drawTextureMirroredXPS;
} }
ShaderPointer StandardShaderLib::getDrawTextureOpaquePS() { ShaderPointer StandardShaderLib::getDrawTextureOpaquePS() {
if (!_drawTextureOpaquePS) { if (!_drawTextureOpaquePS) {
_drawTextureOpaquePS = gpu::Shader::createPixel(std::string(DrawTextureOpaque_frag)); _drawTextureOpaquePS = DrawTextureOpaque_frag::getShader();
} }
return _drawTextureOpaquePS; return _drawTextureOpaquePS;
} }
ShaderPointer StandardShaderLib::getDrawColoredTexturePS() { ShaderPointer StandardShaderLib::getDrawColoredTexturePS() {
if (!_drawColoredTexturePS) { if (!_drawColoredTexturePS) {
_drawColoredTexturePS = gpu::Shader::createPixel(std::string(DrawColoredTexture_frag)); _drawColoredTexturePS = DrawColoredTexture_frag::getShader();
} }
return _drawColoredTexturePS; return _drawColoredTexturePS;
} }

View file

@ -91,8 +91,8 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&] { std::call_once(once, [&] {
{ {
auto skyVS = gpu::Shader::createVertex(std::string(skybox_vert)); auto skyVS = skybox_vert::getShader();
auto skyFS = gpu::Shader::createPixel(std::string(skybox_frag)); auto skyFS = skybox_frag::getShader();
auto skyShader = gpu::Shader::createProgram(skyVS, skyFS); auto skyShader = gpu::Shader::createProgram(skyVS, skyFS);
batch.runLambda([skyShader] { batch.runLambda([skyShader] {

View file

@ -241,7 +241,7 @@ void Procedural::prepare(gpu::Batch& batch, const glm::vec3& position, const glm
std::string fragmentShaderSource = _fragmentSource; std::string fragmentShaderSource = _fragmentSource;
size_t replaceIndex = fragmentShaderSource.find(PROCEDURAL_COMMON_BLOCK); size_t replaceIndex = fragmentShaderSource.find(PROCEDURAL_COMMON_BLOCK);
if (replaceIndex != std::string::npos) { if (replaceIndex != std::string::npos) {
fragmentShaderSource.replace(replaceIndex, PROCEDURAL_COMMON_BLOCK.size(), ProceduralCommon_frag); fragmentShaderSource.replace(replaceIndex, PROCEDURAL_COMMON_BLOCK.size(), ProceduralCommon_frag::getSource());
} }
replaceIndex = fragmentShaderSource.find(PROCEDURAL_VERSION); replaceIndex = fragmentShaderSource.find(PROCEDURAL_VERSION);

View file

@ -19,8 +19,8 @@
#include <graphics/skybox_frag.h> #include <graphics/skybox_frag.h>
ProceduralSkybox::ProceduralSkybox() : graphics::Skybox() { ProceduralSkybox::ProceduralSkybox() : graphics::Skybox() {
_procedural._vertexSource = skybox_vert; _procedural._vertexSource = skybox_vert::getSource();
_procedural._fragmentSource = skybox_frag; _procedural._fragmentSource = skybox_frag::getSource();
// Adjust the pipeline state for background using the stencil test // Adjust the pipeline state for background using the stencil test
_procedural.setDoesFade(false); _procedural.setDoesFade(false);
// Must match PrepareStencil::STENCIL_BACKGROUND // Must match PrepareStencil::STENCIL_BACKGROUND

View file

@ -263,7 +263,7 @@ void AmbientOcclusionEffect::configure(const Config& config) {
const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() { const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() {
if (!_occlusionPipeline) { if (!_occlusionPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_makeOcclusion_frag)); auto ps = ssao_makeOcclusion_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -288,7 +288,7 @@ const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() {
const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() { const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() {
if (!_hBlurPipeline) { if (!_hBlurPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_makeHorizontalBlur_frag)); auto ps = ssao_makeHorizontalBlur_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -311,7 +311,7 @@ const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() {
const gpu::PipelinePointer& AmbientOcclusionEffect::getVBlurPipeline() { const gpu::PipelinePointer& AmbientOcclusionEffect::getVBlurPipeline() {
if (!_vBlurPipeline) { if (!_vBlurPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_makeVerticalBlur_frag)); auto ps = ssao_makeVerticalBlur_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -458,7 +458,7 @@ void DebugAmbientOcclusion::configure(const Config& config) {
const gpu::PipelinePointer& DebugAmbientOcclusion::getDebugPipeline() { const gpu::PipelinePointer& DebugAmbientOcclusion::getDebugPipeline() {
if (!_debugPipeline) { if (!_debugPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(ssao_debugOcclusion_frag)); auto ps = ssao_debugOcclusion_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -9,8 +9,6 @@
#include <qmath.h> #include <qmath.h>
#include "animdebugdraw_vert.h"
#include "animdebugdraw_frag.h"
#include <gpu/Batch.h> #include <gpu/Batch.h>
#include "AbstractViewStateInterface.h" #include "AbstractViewStateInterface.h"
#include "RenderUtilsLogging.h" #include "RenderUtilsLogging.h"
@ -19,6 +17,9 @@
#include "AnimDebugDraw.h" #include "AnimDebugDraw.h"
#include "animdebugdraw_vert.h"
#include "animdebugdraw_frag.h"
class AnimDebugDrawData { class AnimDebugDrawData {
public: public:
@ -101,8 +102,8 @@ AnimDebugDraw::AnimDebugDraw() :
state->setBlendFunction(false, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, state->setBlendFunction(false, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD,
gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA, gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA,
gpu::State::BLEND_OP_ADD, gpu::State::ONE); gpu::State::BLEND_OP_ADD, gpu::State::ONE);
auto vertShader = gpu::Shader::createVertex(std::string(animdebugdraw_vert)); auto vertShader = animdebugdraw_vert::getShader();
auto fragShader = gpu::Shader::createPixel(std::string(animdebugdraw_frag)); auto fragShader = animdebugdraw_frag::getShader();
auto program = gpu::Shader::createProgram(vertShader, fragShader); auto program = gpu::Shader::createProgram(vertShader, fragShader);
_pipeline = gpu::Pipeline::create(program, state); _pipeline = gpu::Pipeline::create(program, state);

View file

@ -57,8 +57,8 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(RenderArgs* ar
} }
if (!_antialiasingPipeline) { if (!_antialiasingPipeline) {
auto vs = gpu::Shader::createVertex(std::string(fxaa_vert)); auto vs = fxaa_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(fxaa_frag)); auto ps = fxaa_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -82,8 +82,8 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(RenderArgs* ar
const gpu::PipelinePointer& Antialiasing::getBlendPipeline() { const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
if (!_blendPipeline) { if (!_blendPipeline) {
auto vs = gpu::Shader::createVertex(std::string(fxaa_vert)); auto vs = fxaa_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(fxaa_blend_frag)); auto ps = fxaa_blend_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -61,7 +61,7 @@ void BloomThreshold::run(const render::RenderContextPointer& renderContext, cons
if (!_pipeline) { if (!_pipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS(); auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(BloomThreshold_frag)); auto ps = BloomThreshold_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -113,7 +113,7 @@ void BloomApply::run(const render::RenderContextPointer& renderContext, const In
if (!_pipeline) { if (!_pipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS(); auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(BloomApply_frag)); auto ps = BloomApply_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -369,8 +369,7 @@ bool DebugDeferredBuffer::pipelineNeedsUpdate(Mode mode, std::string customFile)
const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::string customFile) { const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::string customFile) {
if (pipelineNeedsUpdate(mode, customFile)) { if (pipelineNeedsUpdate(mode, customFile)) {
static const std::string VERTEX_SHADER { debug_deferred_buffer_vert }; static const std::string FRAGMENT_SHADER { debug_deferred_buffer_frag::getSource() };
static const std::string FRAGMENT_SHADER { debug_deferred_buffer_frag };
static const std::string SOURCE_PLACEHOLDER { "//SOURCE_PLACEHOLDER" }; static const std::string SOURCE_PLACEHOLDER { "//SOURCE_PLACEHOLDER" };
static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER); static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER);
Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO, Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO,
@ -380,7 +379,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
bakedFragmentShader.replace(SOURCE_PLACEHOLDER_INDEX, SOURCE_PLACEHOLDER.size(), bakedFragmentShader.replace(SOURCE_PLACEHOLDER_INDEX, SOURCE_PLACEHOLDER.size(),
getShaderSourceCode(mode, customFile)); getShaderSourceCode(mode, customFile));
static const auto vs = gpu::Shader::createVertex(VERTEX_SHADER); const auto vs = debug_deferred_buffer_vert::getShader();
const auto ps = gpu::Shader::createPixel(bakedFragmentShader); const auto ps = gpu::Shader::createPixel(bakedFragmentShader);
const auto program = gpu::Shader::createProgram(vs, ps); const auto program = gpu::Shader::createProgram(vs, ps);

View file

@ -83,7 +83,7 @@ enum DeferredShader_BufferSlot {
LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, 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 gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations);
void DeferredLightingEffect::init() { void DeferredLightingEffect::init() {
_directionalAmbientSphereLightLocations = std::make_shared<LightLocations>(); _directionalAmbientSphereLightLocations = std::make_shared<LightLocations>();
@ -95,14 +95,14 @@ void DeferredLightingEffect::init() {
_localLightLocations = std::make_shared<LightLocations>(); _localLightLocations = std::make_shared<LightLocations>();
_localLightOutlineLocations = std::make_shared<LightLocations>(); _localLightOutlineLocations = std::make_shared<LightLocations>();
loadLightProgram(deferred_light_vert, directional_ambient_light_frag, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations); loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_frag::getShader(), false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
loadLightProgram(deferred_light_vert, directional_skybox_light_frag, false, _directionalSkyboxLight, _directionalSkyboxLightLocations); loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_frag::getShader(), false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_frag, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations); loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_shadow_frag::getShader(), false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_frag, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations); loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_shadow_frag::getShader(), false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
loadLightProgram(deferred_light_vert, local_lights_shading_frag, true, _localLight, _localLightLocations); loadLightProgram(deferred_light_vert::getShader(), local_lights_shading_frag::getShader(), true, _localLight, _localLightLocations);
loadLightProgram(deferred_light_vert, local_lights_drawOutline_frag, true, _localLightOutline, _localLightOutlineLocations); loadLightProgram(deferred_light_vert::getShader(), local_lights_drawOutline_frag::getShader(), true, _localLightOutline, _localLightOutlineLocations);
} }
void DeferredLightingEffect::setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit) { void DeferredLightingEffect::setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit) {
@ -171,12 +171,8 @@ void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch, int cluste
} }
} }
static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* fragSource, LightLocationsPtr& locations) { static gpu::ShaderPointer makeLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, LightLocationsPtr& locations) {
auto VS = gpu::Shader::createVertex(std::string(vertSource)); gpu::ShaderPointer program = gpu::Shader::createProgram(vertShader, fragShader);
auto PS = gpu::Shader::createPixel(std::string(fragSource));
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), DEFERRED_BUFFER_COLOR_UNIT)); slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), DEFERRED_BUFFER_COLOR_UNIT));
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), DEFERRED_BUFFER_NORMAL_UNIT)); slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), DEFERRED_BUFFER_NORMAL_UNIT));
@ -224,9 +220,9 @@ static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* f
return program; return program;
} }
static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) { static void loadLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) {
gpu::ShaderPointer program = makeLightProgram(vertSource, fragSource, locations); gpu::ShaderPointer program = makeLightProgram(vertShader, fragShader, locations);
auto state = std::make_shared<gpu::State>(); auto state = std::make_shared<gpu::State>();
state->setColorWriteMask(true, true, true, false); state->setColorWriteMask(true, true, true, false);

View file

@ -133,7 +133,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
RenderArgs* args = renderContext->args; RenderArgs* args = renderContext->args;
if (!_hazePipeline) { if (!_hazePipeline) {
gpu::ShaderPointer ps = gpu::Shader::createPixel(std::string(Haze_frag)); gpu::ShaderPointer ps = Haze_frag::getShader();
gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);

View file

@ -1946,8 +1946,8 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&] { std::call_once(once, [&] {
auto state = std::make_shared<gpu::State>(); auto state = std::make_shared<gpu::State>();
auto VS = gpu::Shader::createVertex(std::string(glowLine_vert)); auto VS = glowLine_vert::getShader();
auto PS = gpu::Shader::createPixel(std::string(glowLine_frag)); auto PS = glowLine_frag::getShader();
auto program = gpu::Shader::createProgram(VS, PS); auto program = gpu::Shader::createProgram(VS, PS);
state->setCullMode(gpu::State::CULL_NONE); state->setCullMode(gpu::State::CULL_NONE);
state->setDepthTest(true, false, gpu::LESS_EQUAL); state->setDepthTest(true, false, gpu::LESS_EQUAL);
@ -2003,8 +2003,8 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) { void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&]() { std::call_once(once, [&]() {
auto vs = gpu::Shader::createVertex(std::string(standardTransformPNTC_vert)); auto vs = standardTransformPNTC_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(standardDrawTexture_frag)); auto ps = standardDrawTexture_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps); auto program = gpu::Shader::createProgram(vs, ps);
auto state = std::make_shared<gpu::State>(); auto state = std::make_shared<gpu::State>();
@ -2039,8 +2039,8 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bool isLayered) { void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bool isLayered) {
if (!_gridPipeline) { if (!_gridPipeline) {
auto vs = gpu::Shader::createVertex(std::string(standardTransformPNTC_vert)); auto vs = standardTransformPNTC_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(grid_frag)); auto ps = grid_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps); auto program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram((*program)); gpu::Shader::makeProgram((*program));
_gridSlot = program->getUniformBuffers().findLocation("gridBuffer"); _gridSlot = program->getUniformBuffers().findLocation("gridBuffer");
@ -2123,12 +2123,9 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) {
return a.getRaw() == b.getRaw(); return a.getRaw() == b.getRaw();
} }
static void buildWebShader(const std::string& vertShaderText, const std::string& fragShaderText, bool blendEnable, static void buildWebShader(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool blendEnable,
gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) { gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) {
auto VS = gpu::Shader::createVertex(vertShaderText); shaderPointerOut = gpu::Shader::createProgram(vertShader, fragShader);
auto PS = gpu::Shader::createPixel(fragShaderText);
shaderPointerOut = gpu::Shader::createProgram(VS, PS);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
gpu::Shader::makeProgram(*shaderPointerOut, slotBindings); gpu::Shader::makeProgram(*shaderPointerOut, slotBindings);
@ -2151,8 +2148,8 @@ void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent) {
gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) { gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) {
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&]() { std::call_once(once, [&]() {
buildWebShader(simple_vert, simple_opaque_web_browser_frag, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA); buildWebShader(simple_vert::getShader(), simple_opaque_web_browser_frag::getShader(), false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA);
buildWebShader(simple_vert, simple_transparent_web_browser_frag, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA); buildWebShader(simple_vert::getShader(), simple_transparent_web_browser_frag::getShader(), true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA);
}); });
return transparent ? _simpleTransparentWebBrowserPipelineNoAA : _simpleOpaqueWebBrowserPipelineNoAA; return transparent ? _simpleTransparentWebBrowserPipelineNoAA : _simpleOpaqueWebBrowserPipelineNoAA;
@ -2181,9 +2178,9 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
if (!fading) { if (!fading) {
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&]() { std::call_once(once, [&]() {
auto VS = gpu::Shader::createVertex(std::string(simple_vert)); auto VS = simple_vert::getShader();
auto PS = gpu::Shader::createPixel(std::string(simple_textured_frag)); auto PS = simple_textured_frag::getShader();
auto PSUnlit = gpu::Shader::createPixel(std::string(simple_textured_unlit_frag)); auto PSUnlit = simple_textured_unlit_frag::getShader();
_simpleShader = gpu::Shader::createProgram(VS, PS); _simpleShader = gpu::Shader::createProgram(VS, PS);
_unlitShader = gpu::Shader::createProgram(VS, PSUnlit); _unlitShader = gpu::Shader::createProgram(VS, PSUnlit);
@ -2196,9 +2193,9 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
} else { } else {
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&]() { std::call_once(once, [&]() {
auto VS = gpu::Shader::createVertex(std::string(simple_fade_vert)); auto VS = simple_fade_vert::getShader();
auto PS = gpu::Shader::createPixel(std::string(simple_textured_fade_frag)); auto PS = simple_textured_fade_frag::getShader();
auto PSUnlit = gpu::Shader::createPixel(std::string(simple_textured_unlit_fade_frag)); auto PSUnlit = simple_textured_unlit_fade_frag::getShader();
_simpleFadeShader = gpu::Shader::createProgram(VS, PS); _simpleFadeShader = gpu::Shader::createProgram(VS, PS);
_unlitFadeShader = gpu::Shader::createProgram(VS, PSUnlit); _unlitFadeShader = gpu::Shader::createProgram(VS, PSUnlit);

View file

@ -130,8 +130,8 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
fillState->setColorWriteMask(false, false, false, false); fillState->setColorWriteMask(false, false, false, false);
fillState->setCullMode(gpu::State::CULL_FRONT); fillState->setCullMode(gpu::State::CULL_FRONT);
auto vs = gpu::Shader::createVertex(std::string(Highlight_aabox_vert)); auto vs = Highlight_aabox_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(nop_frag)); auto ps = nop_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -313,7 +313,7 @@ const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightSt
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL)); state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(Highlight_frag)); auto ps = Highlight_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -325,7 +325,7 @@ const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightSt
_pipeline = gpu::Pipeline::create(program, state); _pipeline = gpu::Pipeline::create(program, state);
ps = gpu::Shader::createPixel(std::string(Highlight_filled_frag)); ps = Highlight_filled_frag::getShader();
program = gpu::Shader::createProgram(vs, ps); program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram(*program, slotBindings); gpu::Shader::makeProgram(*program, slotBindings);
_pipelineFilled = gpu::Pipeline::create(program, state); _pipelineFilled = gpu::Pipeline::create(program, state);
@ -385,8 +385,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons
} }
void DebugHighlight::initializePipelines() { void DebugHighlight::initializePipelines() {
static const std::string VERTEX_SHADER{ debug_deferred_buffer_vert }; static const std::string FRAGMENT_SHADER{ debug_deferred_buffer_frag::getSource() };
static const std::string FRAGMENT_SHADER{ debug_deferred_buffer_frag };
static const std::string SOURCE_PLACEHOLDER{ "//SOURCE_PLACEHOLDER" }; static const std::string SOURCE_PLACEHOLDER{ "//SOURCE_PLACEHOLDER" };
static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER); static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER);
Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO, Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO,
@ -396,7 +395,7 @@ void DebugHighlight::initializePipelines() {
state->setDepthTest(gpu::State::DepthTest(false, false)); state->setDepthTest(gpu::State::DepthTest(false, false));
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL)); state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
const auto vs = gpu::Shader::createVertex(VERTEX_SHADER); const auto vs = debug_deferred_buffer_vert::getShader();
// Depth shader // Depth shader
{ {
@ -553,14 +552,14 @@ const render::Varying DrawHighlightTask::addSelectItemJobs(JobModel& task, const
#include "model_shadow_frag.h" #include "model_shadow_frag.h"
void DrawHighlightTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) { void DrawHighlightTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) {
auto modelVertex = gpu::Shader::createVertex(std::string(model_shadow_vert)); auto modelVertex = model_shadow_vert::getShader();
auto modelPixel = gpu::Shader::createPixel(std::string(model_shadow_frag)); auto modelPixel = model_shadow_frag::getShader();
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel); gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutSkinned(), ShapeKey::Filter::Builder().withoutSkinned(),
modelProgram, state); modelProgram, state);
auto skinVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert)); auto skinVertex = skin_model_shadow_vert::getShader();
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, modelPixel); gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, modelPixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned(), ShapeKey::Filter::Builder().withSkinned(),

View file

@ -605,8 +605,8 @@ void DebugLightClusters::configure(const Config& config) {
const gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() { const gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() {
if (!_drawClusterGrid) { if (!_drawClusterGrid) {
auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawGrid_vert)); auto vs = lightClusters_drawGrid_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(lightClusters_drawGrid_frag)); auto ps = lightClusters_drawGrid_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -635,7 +635,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterFromDepthPipeline()
if (!_drawClusterFromDepth) { if (!_drawClusterFromDepth) {
// auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawGrid_vert)); // auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawGrid_vert));
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(lightClusters_drawClusterFromDepth_frag)); auto ps = lightClusters_drawClusterFromDepth_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -665,7 +665,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterContentPipeline() {
if (!_drawClusterContent) { if (!_drawClusterContent) {
// auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawClusterContent_vert)); // auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawClusterContent_vert));
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(lightClusters_drawClusterContent_frag)); auto ps = lightClusters_drawClusterContent_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -121,16 +121,16 @@ void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* a
void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* args); void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* args);
void initOverlay3DPipelines(ShapePlumber& plumber, bool depthTest) { void initOverlay3DPipelines(ShapePlumber& plumber, bool depthTest) {
auto vertex = gpu::Shader::createVertex(std::string(overlay3D_vert)); auto vertex = overlay3D_vert::getShader();
auto vertexModel = gpu::Shader::createVertex(std::string(model_vert)); auto vertexModel = model_vert::getShader();
auto pixel = gpu::Shader::createPixel(std::string(overlay3D_frag)); auto pixel = overlay3D_frag::getShader();
auto pixelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_translucent_frag)); auto pixelTranslucent = overlay3D_translucent_frag::getShader();
auto pixelUnlit = gpu::Shader::createPixel(std::string(overlay3D_unlit_frag)); auto pixelUnlit = overlay3D_unlit_frag::getShader();
auto pixelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_translucent_unlit_frag)); auto pixelTranslucentUnlit = overlay3D_translucent_unlit_frag::getShader();
auto pixelModel = gpu::Shader::createPixel(std::string(overlay3D_model_frag)); auto pixelModel = overlay3D_model_frag::getShader();
auto pixelModelTranslucent = gpu::Shader::createPixel(std::string(overlay3D_model_translucent_frag)); auto pixelModelTranslucent = overlay3D_model_translucent_frag::getShader();
auto pixelModelUnlit = gpu::Shader::createPixel(std::string(overlay3D_model_unlit_frag)); auto pixelModelUnlit = overlay3D_model_unlit_frag::getShader();
auto pixelModelTranslucentUnlit = gpu::Shader::createPixel(std::string(overlay3D_model_translucent_unlit_frag)); auto pixelModelTranslucentUnlit = overlay3D_model_translucent_unlit_frag::getShader();
auto opaqueProgram = gpu::Shader::createProgram(vertex, pixel); auto opaqueProgram = gpu::Shader::createProgram(vertex, pixel);
auto translucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucent); auto translucentProgram = gpu::Shader::createProgram(vertex, pixelTranslucent);
@ -187,66 +187,66 @@ void initOverlay3DPipelines(ShapePlumber& plumber, bool depthTest) {
void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) { void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
// Vertex shaders // Vertex shaders
auto simpleVertex = gpu::Shader::createVertex(std::string(simple_vert)); auto simpleVertex = simple_vert::getShader();
auto modelVertex = gpu::Shader::createVertex(std::string(model_vert)); auto modelVertex = model_vert::getShader();
auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert)); auto modelNormalMapVertex = model_normal_map_vert::getShader();
auto modelLightmapVertex = gpu::Shader::createVertex(std::string(model_lightmap_vert)); auto modelLightmapVertex = model_lightmap_vert::getShader();
auto modelLightmapNormalMapVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_vert)); auto modelLightmapNormalMapVertex = model_lightmap_normal_map_vert::getShader();
auto modelTranslucentVertex = gpu::Shader::createVertex(std::string(model_translucent_vert)); auto modelTranslucentVertex = model_translucent_vert::getShader();
auto modelTranslucentNormalMapVertex = gpu::Shader::createVertex(std::string(model_translucent_normal_map_vert)); auto modelTranslucentNormalMapVertex = model_translucent_normal_map_vert::getShader();
auto modelShadowVertex = gpu::Shader::createVertex(std::string(model_shadow_vert)); auto modelShadowVertex = model_shadow_vert::getShader();
auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert)); auto skinModelVertex = skin_model_vert::getShader();
auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert)); auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
auto skinModelShadowVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert)); auto skinModelShadowVertex = skin_model_shadow_vert::getShader();
auto modelLightmapFadeVertex = gpu::Shader::createVertex(std::string(model_lightmap_fade_vert)); auto modelLightmapFadeVertex = model_lightmap_fade_vert::getShader();
auto modelLightmapNormalMapFadeVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_fade_vert)); auto modelLightmapNormalMapFadeVertex = model_lightmap_normal_map_fade_vert::getShader();
auto skinModelFadeVertex = gpu::Shader::createVertex(std::string(skin_model_fade_vert)); auto skinModelFadeVertex = skin_model_fade_vert::getShader();
auto skinModelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_fade_vert)); auto skinModelNormalMapFadeVertex = skin_model_normal_map_fade_vert::getShader();
auto skinModelTranslucentVertex = skinModelFadeVertex; // We use the same because it ouputs world position per vertex auto skinModelTranslucentVertex = skinModelFadeVertex; // We use the same because it ouputs world position per vertex
auto skinModelNormalMapTranslucentVertex = skinModelNormalMapFadeVertex; // We use the same because it ouputs world position per vertex auto skinModelNormalMapTranslucentVertex = skinModelNormalMapFadeVertex; // We use the same because it ouputs world position per vertex
auto modelFadeVertex = gpu::Shader::createVertex(std::string(model_fade_vert)); auto modelFadeVertex = model_fade_vert::getShader();
auto modelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(model_normal_map_fade_vert)); auto modelNormalMapFadeVertex = model_normal_map_fade_vert::getShader();
auto simpleFadeVertex = gpu::Shader::createVertex(std::string(simple_fade_vert)); auto simpleFadeVertex = simple_fade_vert::getShader();
auto modelShadowFadeVertex = gpu::Shader::createVertex(std::string(model_shadow_fade_vert)); auto modelShadowFadeVertex = model_shadow_fade_vert::getShader();
auto skinModelShadowFadeVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_fade_vert)); auto skinModelShadowFadeVertex = skin_model_shadow_fade_vert::getShader();
// Pixel shaders // Pixel shaders
auto simplePixel = gpu::Shader::createPixel(std::string(simple_textured_frag)); auto simplePixel = simple_textured_frag::getShader();
auto simpleUnlitPixel = gpu::Shader::createPixel(std::string(simple_textured_unlit_frag)); auto simpleUnlitPixel = simple_textured_unlit_frag::getShader();
auto simpleTranslucentPixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_frag)); auto simpleTranslucentPixel = simple_transparent_textured_frag::getShader();
auto simpleTranslucentUnlitPixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_unlit_frag)); auto simpleTranslucentUnlitPixel = simple_transparent_textured_unlit_frag::getShader();
auto modelPixel = gpu::Shader::createPixel(std::string(model_frag)); auto modelPixel = model_frag::getShader();
auto modelUnlitPixel = gpu::Shader::createPixel(std::string(model_unlit_frag)); auto modelUnlitPixel = model_unlit_frag::getShader();
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag)); auto modelNormalMapPixel = model_normal_map_frag::getShader();
auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(model_specular_map_frag)); auto modelSpecularMapPixel = model_specular_map_frag::getShader();
auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_frag)); auto modelNormalSpecularMapPixel = model_normal_specular_map_frag::getShader();
auto modelTranslucentPixel = gpu::Shader::createPixel(std::string(model_translucent_frag)); auto modelTranslucentPixel = model_translucent_frag::getShader();
auto modelTranslucentNormalMapPixel = gpu::Shader::createPixel(std::string(model_translucent_normal_map_frag)); auto modelTranslucentNormalMapPixel = model_translucent_normal_map_frag::getShader();
auto modelTranslucentUnlitPixel = gpu::Shader::createPixel(std::string(model_translucent_unlit_frag)); auto modelTranslucentUnlitPixel = model_translucent_unlit_frag::getShader();
auto modelShadowPixel = gpu::Shader::createPixel(std::string(model_shadow_frag)); auto modelShadowPixel = model_shadow_frag::getShader();
auto modelLightmapPixel = gpu::Shader::createPixel(std::string(model_lightmap_frag)); auto modelLightmapPixel = model_lightmap_frag::getShader();
auto modelLightmapNormalMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_frag)); auto modelLightmapNormalMapPixel = model_lightmap_normal_map_frag::getShader();
auto modelLightmapSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag)); auto modelLightmapSpecularMapPixel = model_lightmap_specular_map_frag::getShader();
auto modelLightmapNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag)); auto modelLightmapNormalSpecularMapPixel = model_lightmap_normal_specular_map_frag::getShader();
auto modelLightmapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_fade_frag)); auto modelLightmapFadePixel = model_lightmap_fade_frag::getShader();
auto modelLightmapNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_fade_frag)); auto modelLightmapNormalMapFadePixel = model_lightmap_normal_map_fade_frag::getShader();
auto modelLightmapSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_fade_frag)); auto modelLightmapSpecularMapFadePixel = model_lightmap_specular_map_fade_frag::getShader();
auto modelLightmapNormalSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_fade_frag)); auto modelLightmapNormalSpecularMapFadePixel = model_lightmap_normal_specular_map_fade_frag::getShader();
auto modelFadePixel = gpu::Shader::createPixel(std::string(model_fade_frag)); auto modelFadePixel = model_fade_frag::getShader();
auto modelUnlitFadePixel = gpu::Shader::createPixel(std::string(model_unlit_fade_frag)); auto modelUnlitFadePixel = model_unlit_fade_frag::getShader();
auto modelNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_map_fade_frag)); auto modelNormalMapFadePixel = model_normal_map_fade_frag::getShader();
auto modelSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_specular_map_fade_frag)); auto modelSpecularMapFadePixel = model_specular_map_fade_frag::getShader();
auto modelNormalSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_fade_frag)); auto modelNormalSpecularMapFadePixel = model_normal_specular_map_fade_frag::getShader();
auto modelShadowFadePixel = gpu::Shader::createPixel(std::string(model_shadow_fade_frag)); auto modelShadowFadePixel = model_shadow_fade_frag::getShader();
auto modelTranslucentFadePixel = gpu::Shader::createPixel(std::string(model_translucent_fade_frag)); auto modelTranslucentFadePixel = model_translucent_fade_frag::getShader();
auto modelTranslucentNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_translucent_normal_map_fade_frag)); auto modelTranslucentNormalMapFadePixel = model_translucent_normal_map_fade_frag::getShader();
auto modelTranslucentUnlitFadePixel = gpu::Shader::createPixel(std::string(model_translucent_unlit_fade_frag)); auto modelTranslucentUnlitFadePixel = model_translucent_unlit_fade_frag::getShader();
auto simpleFadePixel = gpu::Shader::createPixel(std::string(simple_textured_fade_frag)); auto simpleFadePixel = simple_textured_fade_frag::getShader();
auto simpleUnlitFadePixel = gpu::Shader::createPixel(std::string(simple_textured_unlit_fade_frag)); auto simpleUnlitFadePixel = simple_textured_unlit_fade_frag::getShader();
auto simpleTranslucentFadePixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_fade_frag)); auto simpleTranslucentFadePixel = simple_transparent_textured_fade_frag::getShader();
auto simpleTranslucentUnlitFadePixel = gpu::Shader::createPixel(std::string(simple_transparent_textured_unlit_fade_frag)); auto simpleTranslucentUnlitFadePixel = simple_transparent_textured_unlit_fade_frag::getShader();
using Key = render::ShapeKey; using Key = render::ShapeKey;
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5); auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5);
@ -448,19 +448,19 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) { void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
// Vertex shaders // Vertex shaders
auto modelVertex = gpu::Shader::createVertex(std::string(model_vert)); auto modelVertex = model_vert::getShader();
auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert)); auto modelNormalMapVertex = model_normal_map_vert::getShader();
auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert)); auto skinModelVertex = skin_model_vert::getShader();
auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert)); auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
auto skinModelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_fade_vert)); auto skinModelNormalMapFadeVertex = skin_model_normal_map_fade_vert::getShader();
// Pixel shaders // Pixel shaders
auto modelPixel = gpu::Shader::createPixel(std::string(forward_model_frag)); auto modelPixel = forward_model_frag::getShader();
auto modelUnlitPixel = gpu::Shader::createPixel(std::string(forward_model_unlit_frag)); auto modelUnlitPixel = forward_model_unlit_frag::getShader();
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(forward_model_normal_map_frag)); auto modelNormalMapPixel = forward_model_normal_map_frag::getShader();
auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(forward_model_specular_map_frag)); auto modelSpecularMapPixel = forward_model_specular_map_frag::getShader();
auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(forward_model_normal_specular_map_frag)); auto modelNormalSpecularMapPixel = forward_model_normal_specular_map_frag::getShader();
auto modelNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_map_fade_frag)); auto modelNormalMapFadePixel = model_normal_map_fade_frag::getShader();
using Key = render::ShapeKey; using Key = render::ShapeKey;
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5); auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5);
@ -590,29 +590,29 @@ void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderAr
} }
void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) { void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) {
auto modelVertex = gpu::Shader::createVertex(std::string(model_shadow_vert)); auto modelVertex = model_shadow_vert::getShader();
auto modelPixel = gpu::Shader::createPixel(std::string(model_shadow_frag)); auto modelPixel = model_shadow_frag::getShader();
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel); gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutSkinned().withoutFade(), ShapeKey::Filter::Builder().withoutSkinned().withoutFade(),
modelProgram, state); modelProgram, state);
auto skinVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert)); auto skinVertex = skin_model_shadow_vert::getShader();
auto skinPixel = gpu::Shader::createPixel(std::string(skin_model_shadow_frag)); auto skinPixel = skin_model_shadow_frag::getShader();
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, skinPixel); gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, skinPixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withoutFade(), ShapeKey::Filter::Builder().withSkinned().withoutFade(),
skinProgram, state); skinProgram, state);
auto modelFadeVertex = gpu::Shader::createVertex(std::string(model_shadow_fade_vert)); auto modelFadeVertex = model_shadow_fade_vert::getShader();
auto modelFadePixel = gpu::Shader::createPixel(std::string(model_shadow_fade_frag)); auto modelFadePixel = model_shadow_fade_frag::getShader();
gpu::ShaderPointer modelFadeProgram = gpu::Shader::createProgram(modelFadeVertex, modelFadePixel); gpu::ShaderPointer modelFadeProgram = gpu::Shader::createProgram(modelFadeVertex, modelFadePixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutSkinned().withFade(), ShapeKey::Filter::Builder().withoutSkinned().withFade(),
modelFadeProgram, state); modelFadeProgram, state);
auto skinFadeVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_fade_vert)); auto skinFadeVertex = skin_model_shadow_fade_vert::getShader();
auto skinFadePixel = gpu::Shader::createPixel(std::string(skin_model_shadow_fade_frag)); auto skinFadePixel = skin_model_shadow_fade_frag::getShader();
gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(skinFadeVertex, skinFadePixel); gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(skinFadeVertex, skinFadePixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withFade(), ShapeKey::Filter::Builder().withSkinned().withFade(),

View file

@ -60,7 +60,7 @@ gpu::PipelinePointer PrepareStencil::getMeshStencilPipeline() {
gpu::PipelinePointer PrepareStencil::getPaintStencilPipeline() { gpu::PipelinePointer PrepareStencil::getPaintStencilPipeline() {
if (!_paintStencilPipeline) { if (!_paintStencilPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(stencil_drawMask_frag)); auto ps = stencil_drawMask_frag::getShader();
auto program = gpu::Shader::createProgram(vs, ps); auto program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::makeProgram((*program)); gpu::Shader::makeProgram((*program));

View file

@ -308,7 +308,7 @@ void diffuseProfileGPU(gpu::TexturePointer& profileMap, RenderArgs* args) {
gpu::PipelinePointer makePipeline; gpu::PipelinePointer makePipeline;
{ {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_makeProfile_frag)); auto ps = subsurfaceScattering_makeProfile_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -344,7 +344,7 @@ void diffuseScatterGPU(const gpu::TexturePointer& profileMap, gpu::TexturePointe
gpu::PipelinePointer makePipeline; gpu::PipelinePointer makePipeline;
{ {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_makeLUT_frag)); auto ps = subsurfaceScattering_makeLUT_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -382,7 +382,7 @@ void computeSpecularBeckmannGPU(gpu::TexturePointer& beckmannMap, RenderArgs* ar
gpu::PipelinePointer makePipeline; gpu::PipelinePointer makePipeline;
{ {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_makeSpecularBeckmann_frag)); auto ps = subsurfaceScattering_makeSpecularBeckmann_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -457,7 +457,7 @@ void DebugSubsurfaceScattering::configure(const Config& config) {
gpu::PipelinePointer DebugSubsurfaceScattering::getScatteringPipeline() { gpu::PipelinePointer DebugSubsurfaceScattering::getScatteringPipeline() {
if (!_scatteringPipeline) { if (!_scatteringPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(subsurfaceScattering_drawScattering_frag)); auto ps = subsurfaceScattering_drawScattering_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -212,7 +212,7 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con
const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() { const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() {
if (!_linearDepthPipeline) { if (!_linearDepthPipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(surfaceGeometry_makeLinearDepth_frag)); auto ps = surfaceGeometry_makeLinearDepth_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -239,7 +239,7 @@ const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() {
const gpu::PipelinePointer& LinearDepthPass::getDownsamplePipeline() { const gpu::PipelinePointer& LinearDepthPass::getDownsamplePipeline() {
if (!_downsamplePipeline) { if (!_downsamplePipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(surfaceGeometry_downsampleDepthNormal_frag)); auto ps = surfaceGeometry_downsampleDepthNormal_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -540,7 +540,7 @@ void SurfaceGeometryPass::run(const render::RenderContextPointer& renderContext,
const gpu::PipelinePointer& SurfaceGeometryPass::getCurvaturePipeline() { const gpu::PipelinePointer& SurfaceGeometryPass::getCurvaturePipeline() {
if (!_curvaturePipeline) { if (!_curvaturePipeline) {
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(surfaceGeometry_makeCurvature_frag)); auto ps = surfaceGeometry_makeCurvature_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -28,7 +28,7 @@ ToneMappingEffect::ToneMappingEffect() {
} }
void ToneMappingEffect::init() { void ToneMappingEffect::init() {
auto blitPS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(toneMapping_frag))); auto blitPS = toneMapping_frag::getShader();
auto blitVS = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); auto blitVS = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
auto blitProgram = gpu::ShaderPointer(gpu::Shader::createProgram(blitVS, blitPS)); auto blitProgram = gpu::ShaderPointer(gpu::Shader::createProgram(blitVS, blitPS));

View file

@ -78,7 +78,7 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs)
const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() { const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {
if (!_keyLightPipeline) { if (!_keyLightPipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS(); auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(zone_drawKeyLight_frag)); auto ps = zone_drawKeyLight_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -99,7 +99,7 @@ const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {
const gpu::PipelinePointer& DebugZoneLighting::getAmbientPipeline() { const gpu::PipelinePointer& DebugZoneLighting::getAmbientPipeline() {
if (!_ambientPipeline) { if (!_ambientPipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS(); auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(zone_drawAmbient_frag)); auto ps = zone_drawAmbient_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -120,7 +120,7 @@ const gpu::PipelinePointer& DebugZoneLighting::getAmbientPipeline() {
const gpu::PipelinePointer& DebugZoneLighting::getBackgroundPipeline() { const gpu::PipelinePointer& DebugZoneLighting::getBackgroundPipeline() {
if (!_backgroundPipeline) { if (!_backgroundPipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS(); auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(zone_drawSkybox_frag)); auto ps = zone_drawSkybox_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -223,9 +223,9 @@ void Font::setupGPU() {
// Setup render pipeline // Setup render pipeline
{ {
auto vertexShader = gpu::Shader::createVertex(std::string(sdf_text3D_vert)); auto vertexShader = sdf_text3D_vert::getShader();
auto pixelShader = gpu::Shader::createPixel(std::string(sdf_text3D_frag)); auto pixelShader = sdf_text3D_frag::getShader();
auto pixelShaderTransparent = gpu::Shader::createPixel(std::string(sdf_text3D_transparent_frag)); auto pixelShaderTransparent = sdf_text3D_transparent_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader); gpu::ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader);
gpu::ShaderPointer programTransparent = gpu::Shader::createProgram(vertexShader, pixelShaderTransparent); gpu::ShaderPointer programTransparent = gpu::Shader::createProgram(vertexShader, pixelShaderTransparent);

View file

@ -210,7 +210,7 @@ BlurGaussian::BlurGaussian(bool generateOutputFramebuffer, unsigned int downsamp
gpu::PipelinePointer BlurGaussian::getBlurVPipeline() { gpu::PipelinePointer BlurGaussian::getBlurVPipeline() {
if (!_blurVPipeline) { if (!_blurVPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianV_frag)); auto ps = blurGaussianV_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -232,7 +232,7 @@ gpu::PipelinePointer BlurGaussian::getBlurVPipeline() {
gpu::PipelinePointer BlurGaussian::getBlurHPipeline() { gpu::PipelinePointer BlurGaussian::getBlurHPipeline() {
if (!_blurHPipeline) { if (!_blurHPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianH_frag)); auto ps = blurGaussianH_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -324,7 +324,7 @@ BlurGaussianDepthAware::BlurGaussianDepthAware(bool generateOutputFramebuffer, c
gpu::PipelinePointer BlurGaussianDepthAware::getBlurVPipeline() { gpu::PipelinePointer BlurGaussianDepthAware::getBlurVPipeline() {
if (!_blurVPipeline) { if (!_blurVPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianDepthAwareV_frag)); auto ps = blurGaussianDepthAwareV_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -347,7 +347,7 @@ gpu::PipelinePointer BlurGaussianDepthAware::getBlurVPipeline() {
gpu::PipelinePointer BlurGaussianDepthAware::getBlurHPipeline() { gpu::PipelinePointer BlurGaussianDepthAware::getBlurHPipeline() {
if (!_blurHPipeline) { if (!_blurHPipeline) {
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(blurGaussianDepthAwareH_frag)); auto ps = blurGaussianDepthAwareH_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -34,8 +34,8 @@ using namespace render;
const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() { const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() {
if (!_drawCellBoundsPipeline) { if (!_drawCellBoundsPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawCellBounds_vert)); auto vs = drawCellBounds_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(drawCellBounds_frag)); auto ps = drawCellBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -59,7 +59,7 @@ const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() {
const gpu::PipelinePointer DrawSceneOctree::getDrawLODReticlePipeline() { const gpu::PipelinePointer DrawSceneOctree::getDrawLODReticlePipeline() {
if (!_drawLODReticlePipeline) { if (!_drawLODReticlePipeline) {
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS(); auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
auto ps = gpu::Shader::createPixel(std::string(drawLODReticle_frag)); auto ps = drawLODReticle_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -162,8 +162,8 @@ void DrawSceneOctree::run(const RenderContextPointer& renderContext, const ItemS
const gpu::PipelinePointer DrawItemSelection::getDrawItemBoundPipeline() { const gpu::PipelinePointer DrawItemSelection::getDrawItemBoundPipeline() {
if (!_drawItemBoundPipeline) { if (!_drawItemBoundPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemBounds_vert)); auto vs = drawItemBounds_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(drawItemBounds_frag)); auto ps = drawItemBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -35,8 +35,8 @@ void DrawStatusConfig::dirtyHelper() {
const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() { const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() {
if (!_drawItemBoundsPipeline) { if (!_drawItemBoundsPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemBounds_vert)); auto vs = drawItemBounds_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(drawItemBounds_frag)); auto ps = drawItemBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;
@ -63,8 +63,8 @@ const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() {
const gpu::PipelinePointer DrawStatus::getDrawItemStatusPipeline() { const gpu::PipelinePointer DrawStatus::getDrawItemStatusPipeline() {
if (!_drawItemStatusPipeline) { if (!_drawItemStatusPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemStatus_vert)); auto vs = drawItemStatus_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(drawItemStatus_frag)); auto ps = drawItemStatus_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -22,8 +22,8 @@
#include <gpu/Context.h> #include <gpu/Context.h>
#include <gpu/StandardShaderLib.h> #include <gpu/StandardShaderLib.h>
#include <drawItemBounds_vert.h> #include "drawItemBounds_vert.h"
#include <drawItemBounds_frag.h> #include "drawItemBounds_frag.h"
using namespace render; using namespace render;
@ -155,8 +155,8 @@ void DrawLight::run(const RenderContextPointer& renderContext, const ItemBounds&
const gpu::PipelinePointer DrawBounds::getPipeline() { const gpu::PipelinePointer DrawBounds::getPipeline() {
if (!_boundsPipeline) { if (!_boundsPipeline) {
auto vs = gpu::Shader::createVertex(std::string(drawItemBounds_vert)); auto vs = drawItemBounds_vert::getShader();
auto ps = gpu::Shader::createPixel(std::string(drawItemBounds_frag)); auto ps = drawItemBounds_frag::getShader();
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
gpu::Shader::BindingSet slotBindings; gpu::Shader::BindingSet slotBindings;

View file

@ -15,7 +15,6 @@ in vec4 varColor;
in vec2 varTexcoord; in vec2 varTexcoord;
out vec4 outFragColor; out vec4 outFragColor;
void main(void) { void main(void) {
float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5); float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5);

View file

@ -101,6 +101,7 @@ public:
show(); show();
makeCurrent(); makeCurrent();
gl::initModuleGl();
gpu::Context::init<gpu::gl::GLBackend>(); gpu::Context::init<gpu::gl::GLBackend>();
makeCurrent(); makeCurrent();
resize(QSize(800, 600)); resize(QSize(800, 600));
@ -135,7 +136,7 @@ const std::string PIXEL_SHADER_DEFINES{ R"GLSL(
#define GPU_TRANSFORM_STEREO_SPLIT_SCREEN #define GPU_TRANSFORM_STEREO_SPLIT_SCREEN
)GLSL" }; )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::string error;
std::vector<char> binary; std::vector<char> binary;
GLuint vs, fs; GLuint vs, fs;
@ -160,54 +161,54 @@ void QTestWindow::draw() {
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&]{ std::call_once(once, [&]{
testShaderBuild(sdf_text3D_vert, sdf_text3D_frag); testShaderBuild(sdf_text3D_vert::getSource(), sdf_text3D_frag::getSource());
testShaderBuild(DrawTransformUnitQuad_vert, DrawTexture_frag); testShaderBuild(DrawTransformUnitQuad_vert::getSource(), DrawTexture_frag::getSource());
testShaderBuild(DrawTexcoordRectTransformUnitQuad_vert, DrawTexture_frag); testShaderBuild(DrawTexcoordRectTransformUnitQuad_vert::getSource(), DrawTexture_frag::getSource());
testShaderBuild(DrawViewportQuadTransformTexcoord_vert, DrawTexture_frag); testShaderBuild(DrawViewportQuadTransformTexcoord_vert::getSource(), DrawTexture_frag::getSource());
testShaderBuild(DrawTransformUnitQuad_vert, DrawTextureOpaque_frag); testShaderBuild(DrawTransformUnitQuad_vert::getSource(), DrawTextureOpaque_frag::getSource());
testShaderBuild(DrawTransformUnitQuad_vert, DrawColoredTexture_frag); testShaderBuild(DrawTransformUnitQuad_vert::getSource(), DrawColoredTexture_frag::getSource());
testShaderBuild(skybox_vert, skybox_frag); testShaderBuild(skybox_vert::getSource(), skybox_frag::getSource());
testShaderBuild(simple_vert, simple_frag); testShaderBuild(simple_vert::getSource(), simple_frag::getSource());
testShaderBuild(simple_vert, simple_textured_frag); testShaderBuild(simple_vert::getSource(), simple_textured_frag::getSource());
testShaderBuild(simple_vert, simple_textured_unlit_frag); testShaderBuild(simple_vert::getSource(), simple_textured_unlit_frag::getSource());
testShaderBuild(deferred_light_vert, directional_ambient_light_frag); testShaderBuild(deferred_light_vert::getSource(), directional_ambient_light_frag::getSource());
testShaderBuild(deferred_light_vert, directional_skybox_light_frag); testShaderBuild(deferred_light_vert::getSource(), directional_skybox_light_frag::getSource());
testShaderBuild(standardTransformPNTC_vert, standardDrawTexture_frag); testShaderBuild(standardTransformPNTC_vert::getSource(), standardDrawTexture_frag::getSource());
testShaderBuild(standardTransformPNTC_vert, DrawTextureOpaque_frag); testShaderBuild(standardTransformPNTC_vert::getSource(), DrawTextureOpaque_frag::getSource());
testShaderBuild(model_vert, model_frag); testShaderBuild(model_vert::getSource(), model_frag::getSource());
testShaderBuild(model_normal_map_vert, model_normal_map_frag); testShaderBuild(model_normal_map_vert::getSource(), model_normal_map_frag::getSource());
testShaderBuild(model_vert, model_specular_map_frag); testShaderBuild(model_vert::getSource(), model_specular_map_frag::getSource());
testShaderBuild(model_normal_map_vert, model_normal_specular_map_frag); testShaderBuild(model_normal_map_vert::getSource(), model_normal_specular_map_frag::getSource());
testShaderBuild(model_vert, model_translucent_frag); testShaderBuild(model_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(model_normal_map_vert, model_translucent_frag); testShaderBuild(model_normal_map_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(model_lightmap_vert, model_lightmap_frag); testShaderBuild(model_lightmap_vert::getSource(), model_lightmap_frag::getSource());
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_map_frag); testShaderBuild(model_lightmap_normal_map_vert::getSource(), model_lightmap_normal_map_frag::getSource());
testShaderBuild(model_lightmap_vert, model_lightmap_specular_map_frag); testShaderBuild(model_lightmap_vert::getSource(), model_lightmap_specular_map_frag::getSource());
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_specular_map_frag); testShaderBuild(model_lightmap_normal_map_vert::getSource(), model_lightmap_normal_specular_map_frag::getSource());
testShaderBuild(skin_model_vert, model_frag); testShaderBuild(skin_model_vert::getSource(), model_frag::getSource());
testShaderBuild(skin_model_normal_map_vert, model_normal_map_frag); testShaderBuild(skin_model_normal_map_vert::getSource(), model_normal_map_frag::getSource());
testShaderBuild(skin_model_vert, model_specular_map_frag); testShaderBuild(skin_model_vert::getSource(), model_specular_map_frag::getSource());
testShaderBuild(skin_model_normal_map_vert, model_normal_specular_map_frag); testShaderBuild(skin_model_normal_map_vert::getSource(), model_normal_specular_map_frag::getSource());
testShaderBuild(skin_model_vert, model_translucent_frag); testShaderBuild(skin_model_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(skin_model_normal_map_vert, model_translucent_frag); testShaderBuild(skin_model_normal_map_vert::getSource(), model_translucent_frag::getSource());
testShaderBuild(model_shadow_vert, model_shadow_frag); testShaderBuild(model_shadow_vert::getSource(), model_shadow_frag::getSource());
testShaderBuild(textured_particle_vert, textured_particle_frag); testShaderBuild(textured_particle_vert::getSource(), textured_particle_frag::getSource());
/* FIXME: Bring back the ssao shader tests /* FIXME: Bring back the ssao shader tests
testShaderBuild(gaussian_blur_vertical_vert, gaussian_blur_frag); testShaderBuild(gaussian_blur_vert::getSource()ical_vert::getSource(), gaussian_blur_frag::getSource());
testShaderBuild(gaussian_blur_horizontal_vert, gaussian_blur_frag); testShaderBuild(gaussian_blur_horizontal_vert::getSource(), gaussian_blur_frag::getSource());
testShaderBuild(ambient_occlusion_vert, ambient_occlusion_frag); testShaderBuild(ambient_occlusion_vert::getSource(), ambient_occlusion_frag::getSource());
testShaderBuild(ambient_occlusion_vert, occlusion_blend_frag); testShaderBuild(ambient_occlusion_vert::getSource(), occlusion_blend_frag::getSource());
*/ */
testShaderBuild(overlay3D_vert, overlay3D_frag); testShaderBuild(overlay3D_vert::getSource(), overlay3D_frag::getSource());
testShaderBuild(paintStroke_vert,paintStroke_frag); testShaderBuild(paintStroke_vert::getSource(),paintStroke_frag::getSource());
testShaderBuild(polyvox_vert, polyvox_frag); testShaderBuild(polyvox_vert::getSource(), polyvox_frag::getSource());
}); });
_context.swapBuffers(this); _context.swapBuffers(this);

View file

@ -1,3 +1,8 @@
set(TARGET_NAME scribe) set(TARGET_NAME scribe)
setup_hifi_project() # don't use the setup_hifi_project macro as we don't want Qt or GLM dependencies
file(GLOB TARGET_SRCS src/*)
add_executable(${TARGET_NAME} ${TARGET_SRCS})
if (WIN32)
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF")
endif()

View file

@ -41,9 +41,23 @@ int main (int argc, char** argv) {
GRAB_VAR_VALUE, GRAB_VAR_VALUE,
GRAB_INCLUDE_PATH, GRAB_INCLUDE_PATH,
GRAB_TARGET_NAME, GRAB_TARGET_NAME,
GRAB_SHADER_TYPE,
EXIT, EXIT,
} mode = READY; } mode = READY;
enum Type {
VERTEX = 0,
FRAGMENT,
GEOMETRY,
} type = VERTEX;
static const char* shaderTypeString[] = {
"VERTEX", "PIXEL", "GEOMETRY"
};
static const char* shaderCreateString[] = {
"Vertex", "Pixel", "Geometry"
};
std::string shaderStage{ "vert" };
for (int ii = 1; (mode != EXIT) && (ii < argc); ii++) { for (int ii = 1; (mode != EXIT) && (ii < argc); ii++) {
inputs.push_back(argv[ii]); inputs.push_back(argv[ii]);
@ -66,6 +80,8 @@ int main (int argc, char** argv) {
} else if (inputs.back() == "-c++") { } else if (inputs.back() == "-c++") {
makeCPlusPlus = true; makeCPlusPlus = true;
mode = READY; mode = READY;
} else if (inputs.back() == "-T") {
mode = GRAB_SHADER_TYPE;
} else { } else {
// just grabbed the source filename, stop parameter parsing // just grabbed the source filename, stop parameter parsing
srcFilename = inputs.back(); srcFilename = inputs.back();
@ -106,6 +122,24 @@ int main (int argc, char** argv) {
} }
break; break;
case GRAB_SHADER_TYPE:
{
if (inputs.back() == "frag") {
shaderStage = inputs.back();
type = FRAGMENT;
} else if (inputs.back() == "geom") {
shaderStage = inputs.back();
type = GEOMETRY;
} else if (inputs.back() == "vert") {
shaderStage = inputs.back();
type = VERTEX;
} else {
cerr << "Unrecognized shader type. Supported is vert, frag or geom" << endl;
}
mode = READY;
}
break;
case EXIT: { case EXIT: {
// THis shouldn't happen // THis shouldn't happen
} }
@ -123,11 +157,13 @@ int main (int argc, char** argv) {
cerr << " varname and varvalue must be made of alpha numerical characters with no spaces." << endl; cerr << " varname and varvalue must be made of alpha numerical characters with no spaces." << endl;
cerr << " -listVars : Will list the vars name and value in the standard output." << endl; cerr << " -listVars : Will list the vars name and value in the standard output." << endl;
cerr << " -showParseTree : Draw the tree obtained while parsing the source" << endl; cerr << " -showParseTree : Draw the tree obtained while parsing the source" << endl;
cerr << " -c++ : Generate a c++ header file containing the output file stream stored as a char[] variable" << endl; cerr << " -c++ : Generate a c++ source file containing the output file stream stored as a char[] variable" << endl;
cerr << " -T vert/frag/geom : define the type of the shader. Defaults to VERTEX if not specified." << endl;
cerr << " This is necessary if the -c++ option is used." << endl;
return 0; return 0;
} }
// Define targetName: if none, get destFilenmae, if none get srcFilename // Define targetName: if none, get destFilename, if none get srcFilename
if (targetName.empty()) { if (targetName.empty()) {
if (destFilename.empty()) { if (destFilename.empty()) {
targetName = srcFilename; targetName = srcFilename;
@ -163,7 +199,7 @@ int main (int argc, char** argv) {
srcStream.open(srcFilename, std::fstream::in); srcStream.open(srcFilename, std::fstream::in);
if (!srcStream.is_open()) { if (!srcStream.is_open()) {
cerr << "Failed to open source file <" << srcFilename << ">" << endl; cerr << "Failed to open source file <" << srcFilename << ">" << endl;
return 0; return 1;
} }
auto scribe = std::make_shared<TextTemplate>(srcFilename, config); auto scribe = std::make_shared<TextTemplate>(srcFilename, config);
@ -173,7 +209,7 @@ int main (int argc, char** argv) {
int numErrors = scribe->scribe(destStringStream, srcStream, vars); int numErrors = scribe->scribe(destStringStream, srcStream, vars);
if (numErrors) { if (numErrors) {
cerr << "Scribe " << srcFilename << "> failed: " << numErrors << " errors." << endl; cerr << "Scribe " << srcFilename << "> failed: " << numErrors << " errors." << endl;
return 0; return 1;
}; };
@ -186,7 +222,6 @@ int main (int argc, char** argv) {
scribe->displayTree(cerr, level); scribe->displayTree(cerr, level);
} }
std::ostringstream targetStringStream;
if (makeCPlusPlus) { if (makeCPlusPlus) {
// Because there is a maximum size for literal strings declared in source we need to partition the // Because there is a maximum size for literal strings declared in source we need to partition the
// full source string stream into pages that seems to be around that value... // full source string stream into pages that seems to be around that value...
@ -208,35 +243,108 @@ int main (int argc, char** argv) {
pageSize += lineSize; pageSize += lineSize;
} }
targetStringStream << "// File generated by Scribe " << vars["_SCRIBE_DATE"] << std::endl; std::stringstream headerStringStream;
targetStringStream << "#ifndef scribe_" << targetName << "_h" << std::endl; std::stringstream sourceStringStream;
targetStringStream << "#define scribe_" << targetName << "_h" << std::endl << std::endl; std::string headerFileName = destFilename + ".h";
std::string sourceFileName = destFilename + ".cpp";
targetStringStream << "const char " << targetName << "[] = \n"; sourceStringStream << "// File generated by Scribe " << vars["_SCRIBE_DATE"] << std::endl;
// Write header file
headerStringStream << "#ifndef " << targetName << "_h" << std::endl;
headerStringStream << "#define " << targetName << "_h\n" << std::endl;
headerStringStream << "#include <gpu/Shader.h>\n" << std::endl;
headerStringStream << "class " << targetName << " {" << std::endl;
headerStringStream << "public:" << std::endl;
headerStringStream << "\tstatic gpu::Shader::Type getType() { return gpu::Shader::" << shaderTypeString[type] << "; }" << std::endl;
headerStringStream << "\tstatic const std::string& getSource() { return _source; }" << std::endl;
headerStringStream << "\tstatic gpu::ShaderPointer getShader();" << std::endl;
headerStringStream << "private:" << std::endl;
headerStringStream << "\tstatic const std::string _source;" << std::endl;
headerStringStream << "\tstatic gpu::ShaderPointer _shader;" << std::endl;
headerStringStream << "};\n" << std::endl;
headerStringStream << "#endif // " << targetName << "_h" << std::endl;
bool mustOutputHeader = destFilename.empty();
// Compare with existing file
{
std::fstream headerFile;
headerFile.open(headerFileName, std::fstream::in);
if (headerFile.is_open()) {
// Skip first line
std::string line;
std::stringstream previousHeaderStringStream;
std::getline(headerFile, line);
previousHeaderStringStream << headerFile.rdbuf();
mustOutputHeader = mustOutputHeader || previousHeaderStringStream.str() != headerStringStream.str();
} else {
mustOutputHeader = true;
}
}
if (mustOutputHeader) {
if (!destFilename.empty()) {
// File content has changed so write it
std::fstream headerFile;
headerFile.open(headerFileName, std::fstream::out);
if (headerFile.is_open()) {
// First line contains the date of modification
headerFile << sourceStringStream.str();
headerFile << headerStringStream.str();
} else {
cerr << "Scribe output file <" << headerFileName << "> failed to open." << endl;
return 1;
}
} else {
cerr << sourceStringStream.str();
cerr << headerStringStream.str();
}
}
// Write source file
sourceStringStream << "#include \"" << targetName << ".h\"\n" << std::endl;
sourceStringStream << "gpu::ShaderPointer " << targetName << "::_shader;" << std::endl;
sourceStringStream << "const std::string " << targetName << "::_source = std::string()";
// Write the pages content // Write the pages content
for (auto page : pages) { for (auto page : pages) {
targetStringStream << "R\"SCRIBE(\n" << page->str() << "\n)SCRIBE\"\n"; sourceStringStream << "+ std::string(R\"SCRIBE(\n" << page->str() << "\n)SCRIBE\")\n";
} }
targetStringStream << ";\n" << std::endl << std::endl; sourceStringStream << ";\n" << std::endl << std::endl;
targetStringStream << "#endif" << std::endl; sourceStringStream << "gpu::ShaderPointer " << targetName << "::getShader() {" << std::endl;
} else { sourceStringStream << "\tif (_shader==nullptr) {" << std::endl;
targetStringStream << destStringStream.str(); sourceStringStream << "\t\t_shader = gpu::Shader::create" << shaderCreateString[type] << "(std::string(_source));" << std::endl;
} sourceStringStream << "\t}" << std::endl;
sourceStringStream << "\treturn _shader;" << std::endl;
sourceStringStream << "}\n" << std::endl;
// Destination stream // Destination stream
if (!destFilename.empty()) { if (!destFilename.empty()) {
std::fstream destFileStream; std::fstream sourceFile;
destFileStream.open(destFilename, std::fstream::out); sourceFile.open(sourceFileName, std::fstream::out);
if (!destFileStream.is_open()) { if (!sourceFile.is_open()) {
cerr << "Scribe output file " << destFilename << "> failed to open." << endl; cerr << "Scribe output file <" << sourceFileName << "> failed to open." << endl;
return 0; return 1;
}
sourceFile << sourceStringStream.str();
} else {
cerr << sourceStringStream.str();
} }
destFileStream << targetStringStream.str();
} else { } else {
cerr << targetStringStream.str(); // Destination stream
if (!destFilename.empty()) {
std::fstream destFileStream;
destFileStream.open(destFilename, std::fstream::out);
if (!destFileStream.is_open()) {
cerr << "Scribe output file <" << destFilename << "> failed to open." << endl;
return 1;
}
destFileStream << destStringStream.str();
} else {
cerr << destStringStream.str();
}
} }
return 0; return 0;