Showing the changes to libraries/render-utils/src/DebugDeferredBuffer.cpp (1 of 4 files). Show all
Unified · Split
| @@ -27,6 +27,14 @@ · 26 unmodified lines | |||
| 27 | 27 | ||
| 28 | using namespace render; | 28 | using namespace render; |
| 29 | 29 | ||
| 30 | void DebugDeferredBufferConfig::setMode(int newMode) { | ||
| 31 | if (newMode > (int)DebugDeferredBuffer::Custom || newMode < 0) { | ||
| 32 | mode = (int)DebugDeferredBuffer::Custom; | ||
| 33 | } else { | ||
| 34 | mode = newMode; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 30 | enum Slots { | 38 | enum Slots { |
| 31 | Diffuse = 0, | 39 | Diffuse = 0, |
| 32 | Normal, | 40 | Normal, |
| @@ -129,37 +137,37 @@ DebugDeferredBuffer::DebugDeferredBuffer() { · 96 unmodified lines | |||
| 129 | _customPipelines.emplace(CUSTOM_FILE, pipeline); | 137 | _customPipelines.emplace(CUSTOM_FILE, pipeline); |
| 130 | } | 138 | } |
| 131 | 139 | ||
| 132 | std::string DebugDeferredBuffer::getShaderSourceCode(Modes mode, std::string customFile) { | 140 | std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string customFile) { |
| 133 | switch (mode) { | 141 | switch (mode) { |
| 134 | case DiffuseMode: | 142 | case Diffuse: |
| 135 | return DEFAULT_DIFFUSE_SHADER; | 143 | return DEFAULT_DIFFUSE_SHADER; |
| 136 | case SpecularMode: | 144 | case Specular: |
| 137 | return DEFAULT_SPECULAR_SHADER; | 145 | return DEFAULT_SPECULAR_SHADER; |
| 138 | case RoughnessMode: | 146 | case Roughness: |
| 139 | return DEFAULT_ROUGHNESS_SHADER; | 147 | return DEFAULT_ROUGHNESS_SHADER; |
| 140 | case NormalMode: | 148 | case Normal: |
| 141 | return DEFAULT_NORMAL_SHADER; | 149 | return DEFAULT_NORMAL_SHADER; |
| 142 | case DepthMode: | 150 | case Depth: |
| 143 | return DEFAULT_DEPTH_SHADER; | 151 | return DEFAULT_DEPTH_SHADER; |
| 144 | case LightingMode: | 152 | case Lighting: |
| 145 | return DEFAULT_LIGHTING_SHADER; | 153 | return DEFAULT_LIGHTING_SHADER; |
| 146 | case ShadowMode: | 154 | case Shadow: |
| 147 | return DEFAULT_SHADOW_SHADER; | 155 | return DEFAULT_SHADOW_SHADER; |
| 148 | case PyramidDepthMode: | 156 | case PyramidDepth: |
| 149 | return DEFAULT_PYRAMID_DEPTH_SHADER; | 157 | return DEFAULT_PYRAMID_DEPTH_SHADER; |
| 150 | case AmbientOcclusionMode: | 158 | case AmbientOcclusion: |
| 151 | return DEFAULT_AMBIENT_OCCLUSION_SHADER; | 159 | return DEFAULT_AMBIENT_OCCLUSION_SHADER; |
| 152 | case AmbientOcclusionBlurredMode: | 160 | case AmbientOcclusionBlurred: |
| 153 | return DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER; | 161 | return DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER; |
| 154 | case CustomMode: | 162 | case Custom: |
| 155 | return getFileContent(customFile, DEFAULT_CUSTOM_SHADER); | 163 | return getFileContent(customFile, DEFAULT_CUSTOM_SHADER); |
| 156 | } | 164 | } |
| 157 | Q_UNREACHABLE(); | 165 | Q_UNREACHABLE(); |
| 158 | return std::string(); | 166 | return std::string(); |
| 159 | } | 167 | } |
| 160 | 168 | ||
| 161 | bool DebugDeferredBuffer::pipelineNeedsUpdate(Modes mode, std::string customFile) const { | 169 | bool DebugDeferredBuffer::pipelineNeedsUpdate(Mode mode, std::string customFile) const { |
| 162 | if (mode != CustomMode) { | 170 | if (mode != Custom) { |
| 163 | return !_pipelines[mode]; | 171 | return !_pipelines[mode]; |
| 164 | } | 172 | } |
| 165 | 173 | ||
| @@ -175,7 +183,7 @@ bool DebugDeferredBuffer::pipelineNeedsUpdate(Modes mode, std::string customFile · 9 unmodified lines | |||
| 175 | return true; | 183 | return true; |
| 176 | } | 184 | } |
| 177 | 185 | ||
| 178 | const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::string customFile) { | 186 | const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::string customFile) { |
| 179 | if (pipelineNeedsUpdate(mode, customFile)) { | 187 | if (pipelineNeedsUpdate(mode, customFile)) { |
| 180 | static const std::string VERTEX_SHADER { debug_deferred_buffer_vert }; | 188 | static const std::string VERTEX_SHADER { debug_deferred_buffer_vert }; |
| 181 | static const std::string FRAGMENT_SHADER { debug_deferred_buffer_frag }; | 189 | static const std::string FRAGMENT_SHADER { debug_deferred_buffer_frag }; |
| @@ -207,14 +215,14 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::st · 25 unmodified lines | |||
| 207 | auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>()); | 215 | auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>()); |
| 208 | 216 | ||
| 209 | // Good to go add the brand new pipeline | 217 | // Good to go add the brand new pipeline |
| 210 | if (mode != CustomMode) { | 218 | if (mode != Custom) { |
| 211 | _pipelines[mode] = pipeline; | 219 | _pipelines[mode] = pipeline; |
| 212 | } else { | 220 | } else { |
| 213 | _customPipelines[customFile].pipeline = pipeline; | 221 | _customPipelines[customFile].pipeline = pipeline; |
| 214 | } | 222 | } |
| 215 | } | 223 | } |
| 216 | 224 | ||
| 217 | if (mode != CustomMode) { | 225 | if (mode != Custom) { |
| 218 | return _pipelines[mode]; | 226 | return _pipelines[mode]; |
| 219 | } else { | 227 | } else { |
| 220 | return _customPipelines[customFile].pipeline; | 228 | return _customPipelines[customFile].pipeline; |
| @@ -227,13 +235,6 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 6 unmodified lines | |||
| 227 | assert(renderContext->getArgs()->_viewFrustum); | 235 | assert(renderContext->getArgs()->_viewFrustum); |
| 228 | RenderArgs* args = renderContext->getArgs(); | 236 | RenderArgs* args = renderContext->getArgs(); |
| 229 | 237 | ||
| 230 | // Guard against unspecified modes | ||
| 231 | auto mode = renderContext->_deferredDebugMode; | ||
| 232 | if (mode > (int)CustomMode) { | ||
| 233 | renderContext->_deferredDebugMode = -1; | ||
| 234 | return; | ||
| 235 | } | ||
| 236 | |||
| 237 | gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { | 238 | gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { |
| 238 | const auto geometryBuffer = DependencyManager::get<GeometryCache>(); | 239 | const auto geometryBuffer = DependencyManager::get<GeometryCache>(); |
| 239 | const auto framebufferCache = DependencyManager::get<FramebufferCache>(); | 240 | const auto framebufferCache = DependencyManager::get<FramebufferCache>(); |
| @@ -250,7 +251,7 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 10 unmodified lines | |||
| 250 | // TODO REMOVE: Temporary until UI | 251 | // TODO REMOVE: Temporary until UI |
| 251 | auto first = _customPipelines.begin()->first; | 252 | auto first = _customPipelines.begin()->first; |
| 252 | 253 | ||
| 253 | batch.setPipeline(getPipeline(Modes(renderContext->_deferredDebugMode), first)); | 254 | batch.setPipeline(getPipeline(_mode, first)); |
| 254 | 255 | ||
| 255 | batch.setResourceTexture(Diffuse, framebufferCache->getDeferredColorTexture()); | 256 | batch.setResourceTexture(Diffuse, framebufferCache->getDeferredColorTexture()); |
| 256 | batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture()); | 257 | batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture()); |
| @@ -263,8 +264,8 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 6 unmodified lines | |||
| 263 | batch.setResourceTexture(AmbientOcclusionBlurred, framebufferCache->getOcclusionBlurredTexture()); | 264 | batch.setResourceTexture(AmbientOcclusionBlurred, framebufferCache->getOcclusionBlurredTexture()); |
| 264 | 265 | ||
| 265 | const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f); | 266 | const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f); |
| 266 | const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y); | 267 | const glm::vec2 bottomLeft(_size.x, _size.y); |
| 267 | const glm::vec2 topRight(renderContext->_deferredDebugSize.z, renderContext->_deferredDebugSize.w); | 268 | const glm::vec2 topRight(_size.z, _size.w); |
| 268 | geometryBuffer->renderQuad(batch, bottomLeft, topRight, color); | 269 | geometryBuffer->renderQuad(batch, bottomLeft, topRight, color); |
| 269 | }); | 270 | }); |
| 270 | } | 271 | } |