From 7fc9fd97ff11076fd0b4e75e4cb1282f499be759 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 10 Jul 2015 11:03:12 -0700 Subject: [PATCH 1/2] Replacing setUniformTexture by setResourceTexture in order to differenciate the 2 types of binding points for the BUffers. --- interface/src/avatar/Avatar.cpp | 2 +- interface/src/ui/ApplicationCompositor.cpp | 2 +- interface/src/ui/ApplicationOverlay.cpp | 2 +- .../src/ui/overlays/BillboardOverlay.cpp | 4 +-- .../RenderableParticleEffectEntityItem.cpp | 2 +- libraries/gpu/src/gpu/Batch.cpp | 8 +++--- libraries/gpu/src/gpu/Batch.h | 6 ++-- libraries/gpu/src/gpu/GLBackend.cpp | 2 +- libraries/gpu/src/gpu/GLBackend.h | 2 +- libraries/gpu/src/gpu/GLBackendPipeline.cpp | 2 +- libraries/model/src/model/Skybox.cpp | 2 +- .../src/DeferredLightingEffect.cpp | 28 +++++++++---------- libraries/render-utils/src/Model.cpp | 10 +++---- .../render-utils/src/RenderDeferredTask.cpp | 2 +- libraries/render-utils/src/TextRenderer3D.cpp | 2 +- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 3d4c158a0b..0dde96c7ce 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -644,7 +644,7 @@ void Avatar::renderBillboard(RenderArgs* renderArgs) { glm::vec2 texCoordBottomRight(1.0f, 1.0f); gpu::Batch& batch = *renderArgs->_batch; - batch.setUniformTexture(0, _billboardTexture->getGPUTexture()); + batch.setResourceTexture(0, _billboardTexture->getGPUTexture()); DependencyManager::get()->bindSimpleProgram(batch, true); DependencyManager::get()->renderQuad(batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index dafa332d53..a1420e3b6a 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -179,7 +179,7 @@ void ApplicationCompositor::bindCursorTexture(gpu::Batch& batch, uint8_t cursorI _cursors[iconId] = DependencyManager::get()-> getImageTexture(iconPath); } - batch.setUniformTexture(0, _cursors[iconId]); + batch.setResourceTexture(0, _cursors[iconId]); } // Draws the FBO texture for the screen diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index e7d220893f..4c3d082bdb 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -196,7 +196,7 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder(RenderArgs* renderAr geometryCache->useSimpleDrawPipeline(batch); batch.setProjectionTransform(mat4()); batch.setModelTransform(mat4()); - batch.setUniformTexture(0, DependencyManager::get()->getWhiteTexture()); + batch.setResourceTexture(0, DependencyManager::get()->getWhiteTexture()); batch._glLineWidth(CONNECTION_STATUS_BORDER_LINE_WIDTH); // TODO animate the disconnect border for some excitement while not connected? diff --git a/interface/src/ui/overlays/BillboardOverlay.cpp b/interface/src/ui/overlays/BillboardOverlay.cpp index 988223765a..1bf4f2a9c7 100644 --- a/interface/src/ui/overlays/BillboardOverlay.cpp +++ b/interface/src/ui/overlays/BillboardOverlay.cpp @@ -87,12 +87,12 @@ void BillboardOverlay::render(RenderArgs* args) { transform.postScale(glm::vec3(getDimensions(), 1.0f)); batch->setModelTransform(transform); - batch->setUniformTexture(0, _texture->getGPUTexture()); + batch->setResourceTexture(0, _texture->getGPUTexture()); DependencyManager::get()->renderQuad(*batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha)); - batch->setUniformTexture(0, args->_whiteTexture); // restore default white color after me + batch->setResourceTexture(0, args->_whiteTexture); // restore default white color after me } } diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index d00728a9eb..2eb95d1bef 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -50,7 +50,7 @@ void RenderableParticleEffectEntityItem::render(RenderArgs* args) { Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; if (textured) { - batch.setUniformTexture(0, _texture->getGPUTexture()); + batch.setResourceTexture(0, _texture->getGPUTexture()); } batch.setModelTransform(getTransformToCenter()); DependencyManager::get()->bindSimpleProgram(batch, textured); diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index b3e6b6117d..b643ba66b8 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -227,15 +227,15 @@ void Batch::setUniformBuffer(uint32 slot, const BufferView& view) { } -void Batch::setUniformTexture(uint32 slot, const TexturePointer& texture) { - ADD_COMMAND(setUniformTexture); +void Batch::setResourceTexture(uint32 slot, const TexturePointer& texture) { + ADD_COMMAND(setResourceTexture); _params.push_back(_textures.cache(texture)); _params.push_back(slot); } -void Batch::setUniformTexture(uint32 slot, const TextureView& view) { - setUniformTexture(slot, view._texture); +void Batch::setResourceTexture(uint32 slot, const TextureView& view) { + setResourceTexture(slot, view._texture); } void Batch::setFramebuffer(const FramebufferPointer& framebuffer) { diff --git a/libraries/gpu/src/gpu/Batch.h b/libraries/gpu/src/gpu/Batch.h index 0cc1a6bee3..6841edb3ef 100644 --- a/libraries/gpu/src/gpu/Batch.h +++ b/libraries/gpu/src/gpu/Batch.h @@ -102,8 +102,8 @@ public: void setUniformBuffer(uint32 slot, const BufferPointer& buffer, Offset offset, Offset size); void setUniformBuffer(uint32 slot, const BufferView& view); // not a command, just a shortcut from a BufferView - void setUniformTexture(uint32 slot, const TexturePointer& view); - void setUniformTexture(uint32 slot, const TextureView& view); // not a command, just a shortcut from a TextureView + void setResourceTexture(uint32 slot, const TexturePointer& view); + void setResourceTexture(uint32 slot, const TextureView& view); // not a command, just a shortcut from a TextureView // Framebuffer Stage void setFramebuffer(const FramebufferPointer& framebuffer); @@ -172,7 +172,7 @@ public: COMMAND_setStateBlendFactor, COMMAND_setUniformBuffer, - COMMAND_setUniformTexture, + COMMAND_setResourceTexture, COMMAND_setFramebuffer, diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 54a54ce2a5..a0320cea1b 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -35,7 +35,7 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = (&::gpu::GLBackend::do_setStateBlendFactor), (&::gpu::GLBackend::do_setUniformBuffer), - (&::gpu::GLBackend::do_setUniformTexture), + (&::gpu::GLBackend::do_setResourceTexture), (&::gpu::GLBackend::do_setFramebuffer), diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index 78b0f0838e..2f511ca8d4 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -309,7 +309,7 @@ protected: // Uniform Stage void do_setUniformBuffer(Batch& batch, uint32 paramOffset); - void do_setUniformTexture(Batch& batch, uint32 paramOffset); + void do_setResourceTexture(Batch& batch, uint32 paramOffset); struct UniformStageState { diff --git a/libraries/gpu/src/gpu/GLBackendPipeline.cpp b/libraries/gpu/src/gpu/GLBackendPipeline.cpp index 3b16c58b20..51a3a24e9b 100755 --- a/libraries/gpu/src/gpu/GLBackendPipeline.cpp +++ b/libraries/gpu/src/gpu/GLBackendPipeline.cpp @@ -188,7 +188,7 @@ void GLBackend::do_setUniformBuffer(Batch& batch, uint32 paramOffset) { (void) CHECK_GL_ERROR(); } -void GLBackend::do_setUniformTexture(Batch& batch, uint32 paramOffset) { +void GLBackend::do_setResourceTexture(Batch& batch, uint32 paramOffset) { GLuint slot = batch._params[paramOffset + 1]._uint; TexturePointer uniformTexture = batch._textures.get(batch._params[paramOffset + 0]._uint); diff --git a/libraries/model/src/model/Skybox.cpp b/libraries/model/src/model/Skybox.cpp index a02c646668..0fb2458f01 100755 --- a/libraries/model/src/model/Skybox.cpp +++ b/libraries/model/src/model/Skybox.cpp @@ -103,7 +103,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky batch.setInputBuffer(gpu::Stream::POSITION, theBuffer, 0, 8); batch.setUniformBuffer(SKYBOX_CONSTANTS_SLOT, theConstants, 0, theConstants->getSize()); batch.setInputFormat(theFormat); - batch.setUniformTexture(0, skybox.getCubemap()); + batch.setResourceTexture(0, skybox.getCubemap()); batch.draw(gpu::TRIANGLE_STRIP, 4); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index a721e0cad3..c8ae000479 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -147,7 +147,7 @@ void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured, if (!config.isTextured()) { // If it is not textured, bind white texture and keep using textured pipeline - batch.setUniformTexture(0, DependencyManager::get()->getWhiteTexture()); + batch.setResourceTexture(0, DependencyManager::get()->getWhiteTexture()); } } @@ -244,13 +244,13 @@ void DeferredLightingEffect::render(RenderArgs* args) { batch.clearColorFramebuffer(freeFBO->getBufferMask(), glm::vec4(0.0f, 0.0f, 0.0f, 0.0f)); - batch.setUniformTexture(0, textureCache->getPrimaryColorTexture()); + batch.setResourceTexture(0, textureCache->getPrimaryColorTexture()); - batch.setUniformTexture(1, textureCache->getPrimaryNormalTexture()); + batch.setResourceTexture(1, textureCache->getPrimaryNormalTexture()); - batch.setUniformTexture(2, textureCache->getPrimarySpecularTexture()); + batch.setResourceTexture(2, textureCache->getPrimarySpecularTexture()); - batch.setUniformTexture(3, textureCache->getPrimaryDepthTexture()); + batch.setResourceTexture(3, textureCache->getPrimaryDepthTexture()); // get the viewport side (left, right, both) int viewport[4]; @@ -275,7 +275,7 @@ void DeferredLightingEffect::render(RenderArgs* args) { const LightLocations* locations = &_directionalLightLocations; bool shadowsEnabled = _viewState->getShadowsEnabled(); if (shadowsEnabled) { - batch.setUniformTexture(4, textureCache->getShadowFramebuffer()->getDepthStencilBuffer()); + batch.setResourceTexture(4, textureCache->getShadowFramebuffer()->getDepthStencilBuffer()); program = _directionalLightShadowMap; locations = &_directionalLightShadowMapLocations; @@ -329,7 +329,7 @@ void DeferredLightingEffect::render(RenderArgs* args) { } if (useSkyboxCubemap) { - batch.setUniformTexture(5, _skybox->getCubemap()); + batch.setResourceTexture(5, _skybox->getCubemap()); } if (locations->lightBufferUnit >= 0) { @@ -377,11 +377,11 @@ void DeferredLightingEffect::render(RenderArgs* args) { } if (useSkyboxCubemap) { - batch.setUniformTexture(5, nullptr); + batch.setResourceTexture(5, nullptr); } if (shadowsEnabled) { - batch.setUniformTexture(4, nullptr); + batch.setResourceTexture(4, nullptr); } glm::vec4 sCoefficients(sWidth / 2.0f, 0.0f, 0.0f, sMin + sWidth / 2.0f); @@ -530,10 +530,10 @@ void DeferredLightingEffect::render(RenderArgs* args) { } // Probably not necessary in the long run because the gpu layer would unbound this texture if used as render target - batch.setUniformTexture(0, nullptr); - batch.setUniformTexture(1, nullptr); - batch.setUniformTexture(2, nullptr); - batch.setUniformTexture(3, nullptr); + batch.setResourceTexture(0, nullptr); + batch.setResourceTexture(1, nullptr); + batch.setResourceTexture(2, nullptr); + batch.setResourceTexture(3, nullptr); args->_context->syncCache(); args->_context->render(batch); @@ -551,7 +551,7 @@ void DeferredLightingEffect::copyBack(RenderArgs* args) { batch.setFramebuffer(textureCache->getPrimaryFramebuffer()); batch.setPipeline(_blitLightBuffer); - batch.setUniformTexture(0, freeFBO->getRenderBuffer(0)); + batch.setResourceTexture(0, freeFBO->getRenderBuffer(0)); batch.setProjectionTransform(glm::mat4()); batch.setViewTransform(Transform()); diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 03140c4dfb..ce325d23cb 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -2031,10 +2031,10 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran } static bool showDiffuse = true; if (showDiffuse && diffuseMap) { - batch.setUniformTexture(0, diffuseMap->getGPUTexture()); + batch.setResourceTexture(0, diffuseMap->getGPUTexture()); } else { - batch.setUniformTexture(0, textureCache->getWhiteTexture()); + batch.setResourceTexture(0, textureCache->getWhiteTexture()); } if (locations->texcoordMatrices >= 0) { @@ -2050,14 +2050,14 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran if (!mesh.tangents.isEmpty()) { Texture* normalMap = networkPart.normalTexture.data(); - batch.setUniformTexture(1, !normalMap ? + batch.setResourceTexture(1, !normalMap ? textureCache->getBlueTexture() : normalMap->getGPUTexture()); } if (locations->specularTextureUnit >= 0) { Texture* specularMap = networkPart.specularTexture.data(); - batch.setUniformTexture(locations->specularTextureUnit, !specularMap ? + batch.setResourceTexture(locations->specularTextureUnit, !specularMap ? textureCache->getWhiteTexture() : specularMap->getGPUTexture()); } @@ -2074,7 +2074,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran GLBATCH(glUniform2f)(locations->emissiveParams, emissiveOffset, emissiveScale); Texture* emissiveMap = networkPart.emissiveTexture.data(); - batch.setUniformTexture(locations->emissiveTextureUnit, !emissiveMap ? + batch.setResourceTexture(locations->emissiveTextureUnit, !emissiveMap ? textureCache->getWhiteTexture() : emissiveMap->getGPUTexture()); } diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 8de5c8af01..cf60c42f98 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -236,7 +236,7 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon batch.setViewTransform(viewMat); batch.setPipeline(getOpaquePipeline()); - batch.setUniformTexture(0, args->_whiteTexture); + batch.setResourceTexture(0, args->_whiteTexture); if (!inItems.empty()) { batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(), 1.f, 0); diff --git a/libraries/render-utils/src/TextRenderer3D.cpp b/libraries/render-utils/src/TextRenderer3D.cpp index a429719b8b..973cddc4d7 100644 --- a/libraries/render-utils/src/TextRenderer3D.cpp +++ b/libraries/render-utils/src/TextRenderer3D.cpp @@ -423,7 +423,7 @@ void Font3D::drawString(gpu::Batch& batch, float x, float y, const QString& str, setupGPU(); batch.setPipeline(_pipeline); - batch.setUniformTexture(_fontLoc, _texture); + batch.setResourceTexture(_fontLoc, _texture); batch._glUniform1i(_outlineLoc, (effectType == TextRenderer3D::OUTLINE_EFFECT)); batch._glUniform4fv(_colorLoc, 1, (const GLfloat*)color); From 98f10e72ec4f5662604d2b93c5357e538e002c34 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 10 Jul 2015 15:20:49 -0700 Subject: [PATCH 2/2] fix the wrong function name that happened missing a merge --- interface/src/audio/AudioScope.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/audio/AudioScope.cpp b/interface/src/audio/AudioScope.cpp index 7a93be80f1..4b4e86e7f4 100644 --- a/interface/src/audio/AudioScope.cpp +++ b/interface/src/audio/AudioScope.cpp @@ -130,7 +130,7 @@ void AudioScope::render(RenderArgs* renderArgs, int width, int height) { auto geometryCache = DependencyManager::get(); geometryCache->useSimpleDrawPipeline(batch); auto textureCache = DependencyManager::get(); - batch.setUniformTexture(0, textureCache->getWhiteTexture()); + batch.setResourceTexture(0, textureCache->getWhiteTexture()); mat4 legacyProjection = glm::ortho(0, width, height, 0, -1000, 1000); batch.setProjectionTransform(legacyProjection); batch.setModelTransform(Transform());