diff options
Diffstat (limited to 'src/gui/rhi/qrhigles2_p.h')
-rw-r--r-- | src/gui/rhi/qrhigles2_p.h | 81 |
1 files changed, 72 insertions, 9 deletions
diff --git a/src/gui/rhi/qrhigles2_p.h b/src/gui/rhi/qrhigles2_p.h index 47d6c3f6d7..4139579864 100644 --- a/src/gui/rhi/qrhigles2_p.h +++ b/src/gui/rhi/qrhigles2_p.h @@ -16,7 +16,7 @@ // #include "qrhi_p.h" -#include "qshaderdescription.h" +#include <rhi/qshaderdescription.h> #include <qopengl.h> #include <QByteArray> #include <QWindow> @@ -27,6 +27,7 @@ QT_BEGIN_NAMESPACE class QOpenGLExtensions; +class QRhiGles2; struct QGles2Buffer : public QRhiBuffer { @@ -214,6 +215,7 @@ struct QGles2TextureRenderTarget : public QRhiTextureRenderTarget QGles2RenderTargetData d; GLuint framebuffer = 0; + GLuint nonMsaaThrowawayDepthTexture = 0; friend class QRhiGles2; }; @@ -331,11 +333,13 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer CompressedImage, CompressedSubImage, BlitFromRenderbuffer, + BlitFromTexture, GenMip, BindComputePipeline, Dispatch, BarriersForPass, - Barrier + Barrier, + InvalidateFramebuffer }; Cmd cmd; @@ -343,6 +347,12 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer // QRhiTexture/Buffer/etc. pointers). union Args { struct { + GLuint timestampQuery; + } beginFrame; + struct { + GLuint timestampQuery; + } endFrame; + struct { float x, y, w, h; float d0, d1; } viewport; @@ -494,10 +504,24 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer int w; int h; GLenum target; - GLuint texture; + GLuint dstTexture; int dstLevel; int dstLayer; - } blitFromRb; + bool isDepthStencil; + } blitFromRenderbuffer; + struct { + GLenum srcTarget; + GLuint srcTexture; + int srcLevel; + int srcLayer; + int w; + int h; + GLenum dstTarget; + GLuint dstTexture; + int dstLevel; + int dstLayer; + bool isDepthStencil; + } blitFromTexture; struct { GLenum target; GLuint texture; @@ -516,6 +540,10 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer struct { GLbitfield barriers; } barrier; + struct { + int attCount; + GLenum att[3]; + } invalidateFramebuffer; } args; }; @@ -531,6 +559,7 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer PassType recordingPass; bool passNeedsResourceTracking; + double lastGpuTime = 0; QRhiRenderTarget *currentTarget; QRhiGraphicsPipeline *currentGraphicsPipeline; QRhiComputePipeline *currentComputePipeline; @@ -626,6 +655,7 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer void resetState() { recordingPass = NoPass; passNeedsResourceTracking = true; + // do not zero lastGpuTime currentTarget = nullptr; resetCommands(); resetCachedState(); @@ -687,6 +717,18 @@ inline bool operator!=(const QGles2CommandBuffer::GraphicsPassState::Blend &a, return !(a == b); } +struct QGles2SwapChainTimestamps +{ + static const int TIMESTAMP_PAIRS = 2; + + bool active[TIMESTAMP_PAIRS] = {}; + GLuint query[TIMESTAMP_PAIRS * 2] = {}; + + void prepare(QRhiGles2 *rhiD); + void destroy(QRhiGles2 *rhiD); + bool tryQueryTimestamps(int pairIndex, QRhiGles2 *rhiD, double *elapsedSec); +}; + struct QGles2SwapChain : public QRhiSwapChain { QGles2SwapChain(QRhiImplementation *rhi); @@ -712,6 +754,8 @@ struct QGles2SwapChain : public QRhiSwapChain QGles2SwapChainRenderTarget rtRight; QGles2CommandBuffer cb; int frameCount = 0; + QGles2SwapChainTimestamps timestamps; + int currentTimestampPairIndex = 0; }; class QRhiGles2 : public QRhiImplementation @@ -854,7 +898,6 @@ public: QGles2RenderTargetData *enqueueBindFramebuffer(QRhiRenderTarget *rt, QGles2CommandBuffer *cbD, bool *wantsColorClear = nullptr, bool *wantsDsClear = nullptr); void enqueueBarriersForPass(QGles2CommandBuffer *cbD); - int effectiveSampleCount(int sampleCount) const; QByteArray shaderSource(const QRhiShaderStage &shaderStage, QShaderVersion *shaderVersion); bool compileShader(GLuint program, const QRhiShaderStage &shaderStage, QShaderVersion *shaderVersion); bool linkProgram(GLuint program); @@ -909,7 +952,13 @@ public: GLsizei, const GLvoid *) = nullptr; void(QOPENGLF_APIENTRYP glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint) = nullptr; - + void(QOPENGLF_APIENTRYP glFramebufferTextureMultiviewOVR)(GLenum, GLenum, GLuint, GLint, + GLint, GLsizei) = nullptr; + void (QOPENGLF_APIENTRYP glQueryCounter)(GLuint, GLenum) = nullptr; + void (QOPENGLF_APIENTRYP glGetQueryObjectui64v)(GLuint, GLenum, quint64 *) = nullptr; + void (QOPENGLF_APIENTRYP glObjectLabel)(GLenum, GLuint, GLsizei, const GLchar *) = nullptr; + void (QOPENGLF_APIENTRYP glFramebufferTexture2DMultisampleEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) = nullptr; + void (QOPENGLF_APIENTRYP glFramebufferTextureMultisampleMultiviewOVR)(GLenum, GLenum, GLuint, GLint, GLsizei, GLint, GLsizei) = nullptr; uint vao = 0; struct Caps { Caps() @@ -941,7 +990,7 @@ public: depthTexture(false), packedDepthStencil(false), needsDepthStencilCombinedAttach(false), - srgbCapableDefaultFramebuffer(false), + srgbWriteControl(false), coreProfile(false), uniformBuffers(false), elementIndexUint(false), @@ -962,7 +1011,13 @@ public: geometryShader(false), texture1D(false), hasDrawBuffersFunc(false), - halfAttributes(false) + halfAttributes(false), + multiView(false), + timestamps(false), + objectLabel(false), + glesMultisampleRenderToTexture(false), + glesMultiviewMultisampleRenderToTexture(false), + unpackRowLength(false) { } int ctxMajor; int ctxMinor; @@ -994,7 +1049,7 @@ public: uint depthTexture : 1; uint packedDepthStencil : 1; uint needsDepthStencilCombinedAttach : 1; - uint srgbCapableDefaultFramebuffer : 1; + uint srgbWriteControl : 1; uint coreProfile : 1; uint uniformBuffers : 1; uint elementIndexUint : 1; @@ -1016,6 +1071,12 @@ public: uint texture1D : 1; uint hasDrawBuffersFunc : 1; uint halfAttributes : 1; + uint multiView : 1; + uint timestamps : 1; + uint objectLabel : 1; + uint glesMultisampleRenderToTexture : 1; + uint glesMultiviewMultisampleRenderToTexture : 1; + uint unpackRowLength : 1; } caps; QGles2SwapChain *currentSwapChain = nullptr; QSet<GLint> supportedCompressedFormats; @@ -1049,6 +1110,7 @@ public: } renderbuffer; struct { GLuint framebuffer; + GLuint nonMsaaThrowawayDepthTexture; } textureRenderTarget; }; }; @@ -1058,6 +1120,7 @@ public: OffscreenFrame(QRhiImplementation *rhi) : cbWrapper(rhi) { } bool active = false; QGles2CommandBuffer cbWrapper; + GLuint tsQueries[2] = {}; } ofr; QHash<QRhiShaderStage, uint> m_shaderCache; |