From 97632534e52434776023946f7546457737b3a654 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 22 Apr 2019 09:14:32 -0700 Subject: [PATCH] REvert unecessary modified files to upstream master, just leaving the true new feature in this branch --- .../hmd/DebugHmdDisplayPlugin.cpp | 5 - .../gpu-gl-common/src/gpu/gl/GLBackend.cpp | 8 +- .../gpu-gl-common/src/gpu/gl/GLBackend.h | 10 +- .../src/gpu/gl/GLBackendTransform.cpp | 45 +- .../gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp | 21 +- libraries/gpu/src/gpu/Context.cpp | 945 ------------------ libraries/gpu/src/gpu/Framebuffer.cpp | 30 +- libraries/gpu/src/gpu/Framebuffer.h | 11 +- libraries/gpu/src/gpu/Texture.h | 8 +- libraries/gpu/src/gpu/Transform.slh | 11 +- libraries/shaders/headers/450/header.glsl | 1 - tools/shadergen.py | 4 - 12 files changed, 21 insertions(+), 1078 deletions(-) diff --git a/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp index cd7478d002..b4527ff90c 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/DebugHmdDisplayPlugin.cpp @@ -26,8 +26,6 @@ bool DebugHmdDisplayPlugin::isSupported() const { void DebugHmdDisplayPlugin::resetSensors() { _currentRenderFrameInfo.renderPose = glm::mat4(); // identity - _currentRenderFrameInfo.renderPose = glm::translate(glm::mat4(), glm::vec3(0.0f, 1.76f, 0.0f)); - } bool DebugHmdDisplayPlugin::beginFrameRender(uint32_t frameIndex) { @@ -37,8 +35,6 @@ bool DebugHmdDisplayPlugin::beginFrameRender(uint32_t frameIndex) { // FIXME simulate head movement //_currentRenderFrameInfo.renderPose = ; //_currentRenderFrameInfo.presentPose = _currentRenderFrameInfo.renderPose; - _currentRenderFrameInfo.renderPose = glm::translate(glm::mat4(), glm::vec3(0.0f, 1.76f, 0.0f)); - _currentRenderFrameInfo.presentPose = _currentRenderFrameInfo.renderPose; withNonPresentThreadLock([&] { _frameInfos[frameIndex] = _currentRenderFrameInfo; @@ -78,7 +74,6 @@ bool DebugHmdDisplayPlugin::internalActivate() { // uncomment to capture a quarter size frame //_renderTargetSize /= 2; _cullingProjection = _eyeProjections[0]; - // This must come after the initialization, so that the values calculated // above are available during the customizeContext call (when not running // in threaded present mode) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index 844c1ce2bf..fef458f536 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -447,24 +447,20 @@ void GLBackend::render(const Batch& batch) { renderPassTransfer(batch); } -//#ifdef GPU_STEREO_DRAWCALL_INSTANCED -#ifdef GPU_STEREO_VIEWPORT_CLIPPED +#ifdef GPU_STEREO_DRAWCALL_INSTANCED if (_stereo.isStereo()) { glEnable(GL_CLIP_DISTANCE0); } #endif -//#endif { GL_PROFILE_RANGE(render_gpu_gl_detail, _stereo.isStereo() ? "Render Stereo" : "Render"); renderPassDraw(batch); } -//#ifdef GPU_STEREO_DRAWCALL_INSTANCED -#ifdef GPU_STEREO_VIEWPORT_CLIPPED +#ifdef GPU_STEREO_DRAWCALL_INSTANCED if (_stereo.isStereo()) { glDisable(GL_CLIP_DISTANCE0); } #endif -//#endif // Restore the saved stereo state for the next batch _stereo._enable = savedStereo; diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 327488da36..ffd0466b79 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -36,8 +36,7 @@ #define GPU_STEREO_TECHNIQUE_DOUBLED_SIMPLE #else //#define GPU_STEREO_TECHNIQUE_DOUBLED_SMARTER -//#define GPU_STEREO_TECHNIQUE_INSTANCED -#define GPU_STEREO_TECHNIQUE_INSTANCED_MULTIVIEWPORT +#define GPU_STEREO_TECHNIQUE_INSTANCED #endif // Let these be configured by the one define picked above @@ -52,13 +51,6 @@ #ifdef GPU_STEREO_TECHNIQUE_INSTANCED #define GPU_STEREO_DRAWCALL_INSTANCED -#define GPU_STEREO_VIEWPORT_CLIPPED -#define GPU_STEREO_CAMERA_BUFFER -#endif - -#ifdef GPU_STEREO_TECHNIQUE_INSTANCED_MULTIVIEWPORT -#define GPU_STEREO_DRAWCALL_INSTANCED -#define GPU_STEREO_MULTI_VIEWPORT #define GPU_STEREO_CAMERA_BUFFER #endif diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp index 698a70af5a..555a0a1e41 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp @@ -39,48 +39,6 @@ void GLBackend::do_setViewportTransform(const Batch& batch, size_t paramOffset) #ifdef GPU_STEREO_DRAWCALL_INSTANCED { - #ifdef GPU_STEREO_MULTI_VIEWPORT - ivec4& vp = _transform._viewport; - auto sideWidth = vp.z / 2; - - vec4 leftRight[3]; - - // Mono - leftRight[0] = vp; - // adding this here as im doing Layered, force the first viewport here to be half of it - leftRight[0].x = 0; - leftRight[0].z = sideWidth; - - // Left side - leftRight[1] = vp; - leftRight[1].x = 0; - leftRight[1].z = sideWidth; - - // right side - leftRight[2] = vp; - leftRight[2].x = sideWidth; - leftRight[2].z = sideWidth; - - glViewportArrayv(0, 3, (float*)leftRight); - - // Where we assign the GL viewport - if (_stereo.isStereo()) { - - // ivec4 leftRight[3]; - // leftRight[0] = vp; - vp.z /= 2; - /* leftRight[1] = vp; // left side - leftRight[2] = vp; // right side - leftRight[2].x += vp.z; - glViewportArrayv(0, 3, (float*) leftRight); -*/ - if (_stereo._pass) { - vp.x += vp.z; - } - } else { - // glViewport(vp.x, vp.y, vp.z, vp.w); - } - #else ivec4& vp = _transform._viewport; glViewport(vp.x, vp.y, vp.z, vp.w); @@ -91,7 +49,6 @@ void GLBackend::do_setViewportTransform(const Batch& batch, size_t paramOffset) vp.x += vp.z; } } - #endif } #else if (!_inRenderTransferPass && !isStereo()) { @@ -166,7 +123,7 @@ void GLBackend::TransformStageState::preUpdate(size_t commandIndex, const Stereo if (_invalidView || _invalidProj || _invalidViewport) { size_t offset = _cameraUboSize * _cameras.size(); - Vec2 finalJitter = _projectionJitter / Vec2(framebufferSize); + Vec2 finalJitter = _projectionJitter / Vec2(framebufferSize); _cameraOffsets.push_back(TransformStageState::Pair(commandIndex, offset)); if (stereo.isStereo()) { diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp index a86e6637a2..7a299e792b 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp @@ -60,23 +60,12 @@ public: } if (gltexture) { - if (!_gpuObject.isLayered()) { - if (gltexture->_target == GL_TEXTURE_2D) { - glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); - } else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) { - glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); - } else { - glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, b._subresource); - } + if (gltexture->_target == GL_TEXTURE_2D) { + glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); + } else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) { + glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); } else { - if (gltexture->_target == GL_TEXTURE_2D) { - glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); - } else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) { - glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); - } else { - glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, - b._subresource); - } + glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, b._subresource); } _colorBuffers.push_back(colorAttachments[unit]); } else { diff --git a/libraries/gpu/src/gpu/Context.cpp b/libraries/gpu/src/gpu/Context.cpp index e3c75a24d6..45ee4263a3 100644 --- a/libraries/gpu/src/gpu/Context.cpp +++ b/libraries/gpu/src/gpu/Context.cpp @@ -421,951 +421,6 @@ void gpu::doInBatch(const char* name, const std::shared_ptr& context, const std::function& f) { auto batch = Context::acquireBatch(name); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - f(*batch); context->appendFrameBatch(batch); } diff --git a/libraries/gpu/src/gpu/Framebuffer.cpp b/libraries/gpu/src/gpu/Framebuffer.cpp index 41406b4b93..e88d986da6 100755 --- a/libraries/gpu/src/gpu/Framebuffer.cpp +++ b/libraries/gpu/src/gpu/Framebuffer.cpp @@ -82,14 +82,6 @@ uint32 Framebuffer::getFrameCount() const { } } -uint16 evalRenderBufferNumLayers(const Texture& texture, uint16 subresource) { - if (subresource == TextureView::UNDEFINED_SUBRESOURCE) { - return texture.getNumSlices(); - } else { - return 1; - } -} - bool Framebuffer::validateTargetCompatibility(const Texture& texture, uint32 subresource) const { if (texture.getType() == Texture::TEX_1D) { return false; @@ -100,8 +92,7 @@ bool Framebuffer::validateTargetCompatibility(const Texture& texture, uint32 sub } else { if ((texture.getWidth() == getWidth()) && (texture.getHeight() == getHeight()) && - (texture.getNumSamples() == getNumSamples()) && - (evalRenderBufferNumLayers(texture, subresource) == getNumLayers())) { + (texture.getNumSamples() == getNumSamples())) { return true; } else { return false; @@ -109,7 +100,7 @@ bool Framebuffer::validateTargetCompatibility(const Texture& texture, uint32 sub } } -void Framebuffer::updateSize(const TexturePointer& texture, uint32 subresource) { +void Framebuffer::updateSize(const TexturePointer& texture) { if (!isEmpty()) { return; } @@ -118,9 +109,8 @@ void Framebuffer::updateSize(const TexturePointer& texture, uint32 subresource) _width = texture->getWidth(); _height = texture->getHeight(); _numSamples = texture->getNumSamples(); - _numLayers = evalRenderBufferNumLayers(*texture, subresource); } else { - _width = _height = _numSamples = _numLayers = 0; + _width = _height = _numSamples = 0; } } @@ -148,14 +138,6 @@ uint16 Framebuffer::getNumSamples() const { } } -uint16 Framebuffer::getNumLayers() const { - if (isSwapchain()) { - return getSwapchain()->getNumLayers(); - } else { - return _numLayers; - } -} - // Render buffers int Framebuffer::setRenderBuffer(uint32 slot, const TexturePointer& texture, uint32 subresource) { if (isSwapchain()) { @@ -182,7 +164,7 @@ int Framebuffer::setRenderBuffer(uint32 slot, const TexturePointer& texture, uin ++_colorStamps[slot]; - updateSize(texture, subresource); + updateSize(texture); // assign the new one _renderBuffers[slot] = TextureView(texture, subresource); @@ -209,7 +191,7 @@ void Framebuffer::removeRenderBuffers() { renderBuffer._texture.reset(); } - updateSize(TexturePointer(nullptr), TextureView::UNDEFINED_SUBRESOURCE); + updateSize(TexturePointer(nullptr)); } @@ -258,7 +240,7 @@ bool Framebuffer::assignDepthStencilBuffer(const TexturePointer& texture, const } ++_depthStamp; - updateSize(texture, subresource); + updateSize(texture); // assign the new one _depthStencilBuffer = TextureView(texture, subresource, format); diff --git a/libraries/gpu/src/gpu/Framebuffer.h b/libraries/gpu/src/gpu/Framebuffer.h index 3d2b869958..47b2775d52 100755 --- a/libraries/gpu/src/gpu/Framebuffer.h +++ b/libraries/gpu/src/gpu/Framebuffer.h @@ -27,7 +27,6 @@ public: uint16 getWidth() const { return _width; } uint16 getHeight() const { return _height; } uint16 getNumSamples() const { return _numSamples; } - uint16 getNumLayers() const { return _numLayers; } bool hasDepthStencil() const { return _hasDepthStencil; } bool isFullscreen() const { return _isFullscreen; } @@ -55,7 +54,6 @@ protected: uint16 _width = 1; uint16 _height = 1; uint16 _numSamples = 1; - uint16 _numLayers = 1; uint16 _swapInterval = 0; bool _hasDepthStencil = false; @@ -117,6 +115,7 @@ public: uint32 getDepthStencilBufferSubresource() const; Format getDepthStencilBufferFormat() const; + // Properties Masks getBufferMask() const { return _bufferMask; } bool isEmpty() const { return (_bufferMask == 0); } @@ -131,10 +130,6 @@ public: uint16 getWidth() const; uint16 getHeight() const; uint16 getNumSamples() const; - - uint16 getNumLayers() const; - bool isLayered() const { return getNumLayers() > 1; } - const std::string& getName() const { return _name; } void setName(const std::string& name) { _name = name; } @@ -175,9 +170,7 @@ protected: uint16 _height = 0; uint16 _numSamples = 0; - uint16 _numLayers = 0; - - void updateSize(const TexturePointer& texture, uint32 subresource); + void updateSize(const TexturePointer& texture); bool assignDepthStencilBuffer(const TexturePointer& texture, const Format& format, uint32 subresource); friend class Serializer; diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 537169bf67..26ff86af9c 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -646,11 +646,9 @@ typedef std::vector< TexturePointer > Textures; class TextureView { public: typedef Resource::Size Size; - - static const uint16 UNDEFINED_SUBRESOURCE { uint16(-1) }; TexturePointer _texture = TexturePointer(NULL); - uint16 _subresource = UNDEFINED_SUBRESOURCE; + uint16 _subresource = 0; Element _element = Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA); TextureView() {}; @@ -662,7 +660,7 @@ public: // create the TextureView and own the Texture TextureView(Texture* newTexture, const Element& element) : _texture(newTexture), - _subresource(UNDEFINED_SUBRESOURCE), + _subresource(0), _element(element) {}; TextureView(const TexturePointer& texture, uint16 subresource, const Element& element) : @@ -684,8 +682,6 @@ public: bool operator !() const { return (!_texture); } bool isValid() const { return bool(_texture); } - - bool isSubresource() const { return (_subresource != UNDEFINED_SUBRESOURCE); } }; typedef std::vector TextureViews; diff --git a/libraries/gpu/src/gpu/Transform.slh b/libraries/gpu/src/gpu/Transform.slh index 484ad7ebd2..3015de7e0e 100644 --- a/libraries/gpu/src/gpu/Transform.slh +++ b/libraries/gpu/src/gpu/Transform.slh @@ -168,17 +168,10 @@ TransformObject getTransformObject() { vec2 eyeOffsetScale = vec2(-0.5, +0.5); uint eyeIndex = uint(_stereoSide); #if !defined(GPU_GLES) || (defined(HAVE_EXT_clip_cull_distance) && !defined(VULKAN)) -#ifdef GPU_GL450 - /* gl_ViewportIndex = _stereoSide + 1; - // gl_ViewportIndex = 2 - _stereoSide; - */// THIs is the layered version - gl_Layer = _stereoSide; -#else gl_ClipDistance[0] = dot(<$clipPos$>, eyeClipEdge[eyeIndex]); #endif -#endif - // float newClipPosX = <$clipPos$>.x * 0.5 + eyeOffsetScale[eyeIndex] * <$clipPos$>.w; - // <$clipPos$>.x = newClipPosX; + float newClipPosX = <$clipPos$>.x * 0.5 + eyeOffsetScale[eyeIndex] * <$clipPos$>.w; + <$clipPos$>.x = newClipPosX; #endif #else diff --git a/libraries/shaders/headers/450/header.glsl b/libraries/shaders/headers/450/header.glsl index e3f0021d16..ef0ec09414 100644 --- a/libraries/shaders/headers/450/header.glsl +++ b/libraries/shaders/headers/450/header.glsl @@ -1,4 +1,3 @@ -#extension GL_ARB_shader_viewport_layer_array : require #define GPU_SSBO_TRANSFORM_OBJECT #define BITFIELD int #define LAYOUT(X) layout(X) diff --git a/tools/shadergen.py b/tools/shadergen.py index 4ce4d2818f..f82b471f17 100644 --- a/tools/shadergen.py +++ b/tools/shadergen.py @@ -215,10 +215,6 @@ def processCommand(line): if (dialect == '310es'): spirvCrossDialect = '320es' spirvCrossArgs = [spirvCrossExec, '--output', glslFile, spirvFile, '--version', spirvCrossDialect] if (dialect == '410'): spirvCrossArgs.append('--no-420pack-extension') - if (dialect == '450'): - spirvCrossArgs.append('--extension') - spirvCrossArgs.append('GL_ARB_shader_viewport_layer_array') - executeSubprocess(spirvCrossArgs) else: # This logic is necessary because cmake will agressively keep re-executing the shadergen