5#include <QOffscreenSurface>
6#include <QOpenGLContext>
7#include <QtCore/qmap.h>
8#include <QtGui/private/qopenglextensions_p.h>
9#include <QtGui/private/qopenglprogrambinarycache_p.h>
10#include <qpa/qplatformopenglcontext.h>
155#define GL_BGRA 0x80E1
175#define GL_RG16 0x822C
183#define GL_RGBA8 0x8058
187#define GL_RGBA32F 0x8814
191#define GL_RGBA16F 0x881A
195#define GL_R16F 0x822D
199#define GL_R32F 0x822E
203#define GL_HALF_FLOAT 0x140B
206#ifndef GL_DEPTH_COMPONENT16
207#define GL_DEPTH_COMPONENT16 0x81A5
210#ifndef GL_DEPTH_COMPONENT24
211#define GL_DEPTH_COMPONENT24 0x81A6
214#ifndef GL_DEPTH_COMPONENT32F
215#define GL_DEPTH_COMPONENT32F 0x8CAC
218#ifndef GL_UNSIGNED_INT_24_8
219#define GL_UNSIGNED_INT_24_8 0x84FA
222#ifndef GL_STENCIL_INDEX
223#define GL_STENCIL_INDEX 0x1901
226#ifndef GL_STENCIL_INDEX8
227#define GL_STENCIL_INDEX8 0x8D48
230#ifndef GL_DEPTH24_STENCIL8
231#define GL_DEPTH24_STENCIL8 0x88F0
234#ifndef GL_DEPTH_STENCIL_ATTACHMENT
235#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
238#ifndef GL_DEPTH_STENCIL
239#define GL_DEPTH_STENCIL 0x84F9
242#ifndef GL_PRIMITIVE_RESTART_FIXED_INDEX
243#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
246#ifndef GL_FRAMEBUFFER_SRGB
247#define GL_FRAMEBUFFER_SRGB 0x8DB9
250#ifndef GL_READ_FRAMEBUFFER
251#define GL_READ_FRAMEBUFFER 0x8CA8
254#ifndef GL_DRAW_FRAMEBUFFER
255#define GL_DRAW_FRAMEBUFFER 0x8CA9
258#ifndef GL_MAX_DRAW_BUFFERS
259#define GL_MAX_DRAW_BUFFERS 0x8824
262#ifndef GL_TEXTURE_COMPARE_MODE
263#define GL_TEXTURE_COMPARE_MODE 0x884C
266#ifndef GL_COMPARE_REF_TO_TEXTURE
267#define GL_COMPARE_REF_TO_TEXTURE 0x884E
270#ifndef GL_TEXTURE_COMPARE_FUNC
271#define GL_TEXTURE_COMPARE_FUNC 0x884D
274#ifndef GL_MAX_SAMPLES
275#define GL_MAX_SAMPLES 0x8D57
278#ifndef GL_SHADER_STORAGE_BUFFER
279#define GL_SHADER_STORAGE_BUFFER 0x90D2
283#define GL_READ_ONLY 0x88B8
287#define GL_WRITE_ONLY 0x88B9
291#define GL_READ_WRITE 0x88BA
294#ifndef GL_COMPUTE_SHADER
295#define GL_COMPUTE_SHADER 0x91B9
298#ifndef GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT
299#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
302#ifndef GL_ELEMENT_ARRAY_BARRIER_BIT
303#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
306#ifndef GL_UNIFORM_BARRIER_BIT
307#define GL_UNIFORM_BARRIER_BIT 0x00000004
310#ifndef GL_BUFFER_UPDATE_BARRIER_BIT
311#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
314#ifndef GL_SHADER_STORAGE_BARRIER_BIT
315#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000
318#ifndef GL_TEXTURE_FETCH_BARRIER_BIT
319#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
322#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
323#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
326#ifndef GL_PIXEL_BUFFER_BARRIER_BIT
327#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
330#ifndef GL_TEXTURE_UPDATE_BARRIER_BIT
331#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
334#ifndef GL_FRAMEBUFFER_BARRIER_BIT
335#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
338#ifndef GL_ALL_BARRIER_BITS
339#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
342#ifndef GL_VERTEX_PROGRAM_POINT_SIZE
343#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
346#ifndef GL_POINT_SPRITE
347#define GL_POINT_SPRITE 0x8861
350#ifndef GL_MAP_READ_BIT
351#define GL_MAP_READ_BIT 0x0001
354#ifndef GL_MAP_WRITE_BIT
355#define GL_MAP_WRITE_BIT 0x0002
358#ifndef GL_TEXTURE_2D_MULTISAMPLE
359#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
362#ifndef GL_TEXTURE_2D_MULTISAMPLE_ARRAY
363#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
366#ifndef GL_TEXTURE_EXTERNAL_OES
367#define GL_TEXTURE_EXTERNAL_OES 0x8D65
370#ifndef GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS
371#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB
374#ifndef GL_MAX_COMPUTE_WORK_GROUP_COUNT
375#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE
378#ifndef GL_MAX_COMPUTE_WORK_GROUP_SIZE
379#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF
382#ifndef GL_TEXTURE_CUBE_MAP_SEAMLESS
383#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
386#ifndef GL_CONTEXT_LOST
387#define GL_CONTEXT_LOST 0x0507
390#ifndef GL_PROGRAM_BINARY_LENGTH
391#define GL_PROGRAM_BINARY_LENGTH 0x8741
394#ifndef GL_NUM_PROGRAM_BINARY_FORMATS
395#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
398#ifndef GL_UNPACK_ROW_LENGTH
399#define GL_UNPACK_ROW_LENGTH 0x0CF2
403#define GL_TEXTURE_3D 0x806F
406#ifndef GL_TEXTURE_WRAP_R
407#define GL_TEXTURE_WRAP_R 0x8072
410#ifndef GL_TEXTURE_RECTANGLE
411#define GL_TEXTURE_RECTANGLE 0x84F5
414#ifndef GL_TEXTURE_2D_ARRAY
415#define GL_TEXTURE_2D_ARRAY 0x8C1A
418#ifndef GL_MAX_ARRAY_TEXTURE_LAYERS
419#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
422#ifndef GL_MAX_VERTEX_UNIFORM_COMPONENTS
423#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
426#ifndef GL_MAX_FRAGMENT_UNIFORM_COMPONENTS
427#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
430#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS
431#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
434#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS
435#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
439#define GL_RGB10_A2 0x8059
442#ifndef GL_UNSIGNED_INT_2_10_10_10_REV
443#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
446#ifndef GL_MAX_VARYING_COMPONENTS
447#define GL_MAX_VARYING_COMPONENTS 0x8B4B
450#ifndef GL_MAX_VARYING_FLOATS
451#define GL_MAX_VARYING_FLOATS 0x8B4B
454#ifndef GL_MAX_VARYING_VECTORS
455#define GL_MAX_VARYING_VECTORS 0x8DFC
458#ifndef GL_TESS_CONTROL_SHADER
459#define GL_TESS_CONTROL_SHADER 0x8E88
462#ifndef GL_TESS_EVALUATION_SHADER
463#define GL_TESS_EVALUATION_SHADER 0x8E87
466#ifndef GL_PATCH_VERTICES
467#define GL_PATCH_VERTICES 0x8E72
471#define GL_LINE 0x1B01
475#define GL_FILL 0x1B02
479#define GL_PATCHES 0x000E
482#ifndef GL_GEOMETRY_SHADER
483#define GL_GEOMETRY_SHADER 0x8DD9
487#define GL_BACK_LEFT 0x0402
491#define GL_BACK_RIGHT 0x0403
495# define GL_TEXTURE_1D 0x0DE0
498#ifndef GL_TEXTURE_1D_ARRAY
499# define GL_TEXTURE_1D_ARRAY 0x8C18
503#define GL_HALF_FLOAT 0x140B
506#ifndef GL_MAX_VERTEX_OUTPUT_COMPONENTS
507#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
515QRhiGles2InitParams::QRhiGles2InitParams()
547 qWarning(
"QRhiGles2: Failed to create temporary context");
566 ctx = importDevice->context;
568 qWarning(
"No OpenGL context given, cannot import");
586 return currentSurface;
594#if defined(Q_OS_MACOS)
619 if (!
ctx->makeCurrent(surface)) {
620 if (
ctx->isValid()) {
621 qWarning(
"QRhiGles2: Failed to make context current. Expect bad things to happen.");
623 qWarning(
"QRhiGles2: Context is lost.");
637 return srgb ? 0x8C4C : 0x83F0;
639 return srgb ? 0x8C4E : 0x83F2;
641 return srgb ? 0x8C4F : 0x83F3;
644 return srgb ? 0x9275 : 0x9274;
646 return srgb ? 0x9277 : 0x9276;
648 return srgb ? 0x9279 : 0x9278;
651 return srgb ? 0x93D0 : 0x93B0;
653 return srgb ? 0x93D1 : 0x93B1;
655 return srgb ? 0x93D2 : 0x93B2;
657 return srgb ? 0x93D3 : 0x93B3;
659 return srgb ? 0x93D4 : 0x93B4;
661 return srgb ? 0x93D5 : 0x93B5;
663 return srgb ? 0x93D6 : 0x93B6;
665 return srgb ? 0x93D7 : 0x93B7;
667 return srgb ? 0x93D8 : 0x93B8;
669 return srgb ? 0x93D9 : 0x93B9;
671 return srgb ? 0x93DA : 0x93BA;
673 return srgb ? 0x93DB : 0x93BB;
675 return srgb ? 0x93DC : 0x93BC;
677 return srgb ? 0x93DD : 0x93BD;
696 ctx->setShareContext(shareContext);
697 ctx->setScreen(shareContext->screen());
701 if (!
ctx->create()) {
702 qWarning(
"QRhiGles2: Failed to create context");
707 qCDebug(QRHI_LOG_INFO) <<
"Created OpenGL context" <<
ctx->format();
744 glFramebufferTexture1D =
749 const char *vendor =
reinterpret_cast<const char *
>(
f->glGetString(GL_VENDOR));
750 const char *
renderer =
reinterpret_cast<const char *
>(
f->glGetString(GL_RENDERER));
751 const char *version =
reinterpret_cast<const char *
>(
f->glGetString(GL_VERSION));
753 qCDebug(QRHI_LOG_INFO,
"OpenGL VENDOR: %s RENDERER: %s VERSION: %s", vendor,
renderer, version);
788 std::array<QRhiTexture::Flags, 2> textureVariantFlags;
789 textureVariantFlags[0] = {};
792 for (QRhiTexture::Flags
f : textureVariantFlags) {
799 for (QRhiTexture::Flags
f : textureVariantFlags) {
806 for (QRhiTexture::Flags
f : textureVariantFlags) {
965 GLint maxArraySize = 0;
976 GLint maxVertexUniformVectors = 0;
978 GLint maxFragmentUniformVectors = 0;
982 GLint maxVertexUniformComponents = 0;
984 GLint maxFragmentUniformComponents = 0;
1024 glFramebufferTextureMultiviewOVR =
1045 f->glDeleteVertexArrays(1, &
vao);
1067 f->glDeleteBuffers(1, &
e.buffer.buffer);
1070 f->glDeleteProgram(
e.pipeline.program);
1073 f->glDeleteTextures(1, &
e.texture.texture);
1076 f->glDeleteRenderbuffers(1, &
e.renderbuffer.renderbuffer);
1077 f->glDeleteRenderbuffers(1, &
e.renderbuffer.renderbuffer2);
1080 f->glDeleteFramebuffers(1, &
e.textureRenderTarget.framebuffer);
1103 const int s =
qBound(1, sampleCount, 64);
1105 qWarning(
"Attempted to set unsupported sample count %d", sampleCount);
1167 *glsizedintformat = *glintformat;
1169 *gltype = GL_UNSIGNED_SHORT;
1173 *glsizedintformat = *glintformat;
1175 *gltype = GL_UNSIGNED_SHORT;
1178 *glintformat =
GL_R8;
1179 *glsizedintformat = *glintformat;
1185 *glsizedintformat = *glintformat;
1191 *glsizedintformat = *glintformat;
1197 *glsizedintformat = *glintformat;
1203 *glsizedintformat = *glintformat;
1209 *glsizedintformat = *glintformat;
1215 *glsizedintformat = *glintformat;
1221 *glsizedintformat = *glintformat;
1227 *glsizedintformat = *glintformat;
1228 *glformat = GL_DEPTH_COMPONENT;
1229 *gltype = GL_UNSIGNED_SHORT;
1233 *glsizedintformat = *glintformat;
1234 *glformat = GL_DEPTH_COMPONENT;
1235 *gltype = GL_UNSIGNED_INT;
1239 *glsizedintformat = *glintformat;
1245 *glsizedintformat = *glintformat;
1246 *glformat = GL_DEPTH_COMPONENT;
1394 Q_UNREACHABLE_RETURN(
false);
1432 Q_UNREACHABLE_RETURN(0);
1503 header.driver[driverStrLen] =
'\0';
1505 const size_t dataOffset =
sizeof(
header);
1514 char *
p =
buf.data() + dataOffset;
1523 memcpy(
p,
key.constData(),
key.size());
1529 memcpy(
p,
data.constData(),
data.size());
1550 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: Invalid blob size (header incomplete)");
1558 if (
header.rhiId != rhiId) {
1559 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: The data is for a different QRhi version or backend (%u, %u)",
1564 if (
header.arch != arch) {
1565 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: Architecture does not match (%u, %u)",
1569 if (
header.programBinaryCount == 0)
1574 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: OpenGL vendor/renderer/version does not match");
1579 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: Invalid blob size (data incomplete)");
1585 const char *
p =
data.constData() + dataOffset;
1611 int sampleCount, QRhiRenderBuffer::Flags
flags,
1618 const QSize &pixelSize,
int depth,
int arraySize,
1619 int sampleCount, QRhiTexture::Flags
flags)
1628 return new QGles2Sampler(
this, magFilter, minFilter, mipmapMode, u,
v,
w);
1632 QRhiTextureRenderTarget::Flags
flags)
1659 if (pipelineChanged) {
1671 int dynamicOffsetCount,
1697 for (
int elem = 0; elem <
b->u.stex.count; ++elem) {
1785 for (
int i = 0;
i < dynamicOffsetCount; ++
i) {
1787 *
p++ =
uint(dynOfs.first);
1788 *
p++ = dynOfs.second;
1791 qWarning(
"Too many dynamic offsets (%d, max is %d)",
1806 for (
int i = 0;
i < bindingCount; ++
i) {
1847 const std::array<float, 4>
r =
viewport.viewport();
1849 if (
r[2] < 0.0f ||
r[3] < 0.0f)
1867 const std::array<int, 4>
r = scissor.
scissor();
1869 if (
r[2] < 0 ||
r[3] < 0)
2000 f->glBindVertexArray(0);
2042 ctx->handle()->beginFrame();
2076 ctx->handle()->endFrame();
2187 if (
access == prevAccess)
2210 if (
access == prevAccess)
2260 }
else if (!rawData.
isEmpty() && isCompressed) {
2276 byteSize *= arraySize;
2324 }
else if (!rawData.
isEmpty()) {
2347 if (subresDesc.
dataStride() && bytesPerPixel)
2513 return GL_TRIANGLES;
2515 return GL_TRIANGLE_STRIP;
2517 return GL_TRIANGLE_FAN;
2521 return GL_LINE_STRIP;
2527 Q_UNREACHABLE_RETURN(GL_TRIANGLES);
2539 Q_UNREACHABLE_RETURN(GL_BACK);
2551 Q_UNREACHABLE_RETURN(GL_CCW);
2563 return GL_SRC_COLOR;
2565 return GL_ONE_MINUS_SRC_COLOR;
2567 return GL_DST_COLOR;
2569 return GL_ONE_MINUS_DST_COLOR;
2571 return GL_SRC_ALPHA;
2573 return GL_ONE_MINUS_SRC_ALPHA;
2575 return GL_DST_ALPHA;
2577 return GL_ONE_MINUS_DST_ALPHA;
2587 return GL_SRC_ALPHA_SATURATE;
2592 qWarning(
"Unsupported blend factor %d",
f);
2595 Q_UNREACHABLE_RETURN(GL_ZERO);
2637 Q_UNREACHABLE_RETURN(GL_ALWAYS);
2661 Q_UNREACHABLE_RETURN(GL_KEEP);
2673 Q_UNREACHABLE_RETURN(
GL_FILL);
2691 Q_UNREACHABLE_RETURN(GL_LINEAR);
2703 Q_UNREACHABLE_RETURN(GL_LINEAR);
2741 Q_UNREACHABLE_RETURN(GL_NEVER);
2855 state->currentArrayBuffer = 0;
2856 state->currentElementArrayBuffer = 0;
2857 state->lastBindVertexBuffer.buffer = 0;
2872 f->glGenVertexArrays(1, &
vao);
2873 f->glBindVertexArray(
vao);
2877 if (
state.instancedAttributesUsed) {
2879 if (
state.nonzeroAttribDivisor[
i])
2880 f->glVertexAttribDivisor(
GLuint(
i), 0);
2883 f->glVertexAttribDivisor(
GLuint(
i), 0);
2884 state.instancedAttributesUsed =
false;
2888 if (
state.enabledAttribArrays[
i]) {
2889 f->glDisableVertexAttribArray(
GLuint(
i));
2890 state.enabledAttribArrays[
i] =
false;
2895 f->glBindVertexArray(0);
2899 f->glBindVertexArray(
vao);
2920 qWarning(
"No graphics pipeline active for setStencilRef; ignored");
2928 if (
state.lastBindVertexBuffer.ps == psD
2938 state.lastBindVertexBuffer.ps = psD;
2951 const int bindingIdx =
it->binding();
2960 switch (
it->format()) {
2993 type = GL_UNSIGNED_INT;
2997 type = GL_UNSIGNED_INT;
3001 type = GL_UNSIGNED_INT;
3005 type = GL_UNSIGNED_INT;
3044 const int locationIdx =
it->location();
3046 if (
type == GL_UNSIGNED_INT ||
type == GL_INT) {
3049 reinterpret_cast<const GLvoid *
>(
quintptr(ofs)));
3051 qWarning(
"Current RHI backend does not support IntAttributes. Check supported features.");
3054 state.enabledAttribArrays[locationIdx] =
true;
3058 reinterpret_cast<const GLvoid *
>(
quintptr(ofs)));
3062 state.enabledAttribArrays[locationIdx] =
true;
3063 f->glEnableVertexAttribArray(
GLuint(locationIdx));
3068 state.nonzeroAttribDivisor[locationIdx] =
true;
3070 state.maxUntrackedInstancedAttribute =
qMax(
state.maxUntrackedInstancedAttribute, locationIdx);
3071 state.instancedAttributesUsed =
true;
3073 &&
state.nonzeroAttribDivisor[locationIdx])
3075 && locationIdx <=
state.maxUntrackedInstancedAttribute))
3077 f->glVertexAttribDivisor(
GLuint(locationIdx), 0);
3079 state.nonzeroAttribDivisor[locationIdx] =
false;
3083 qWarning(
"No graphics pipeline active for setVertexInput; ignored");
3107 qWarning(
"No graphics pipeline active for draw; ignored");
3115 const GLvoid *ofs =
reinterpret_cast<const GLvoid *
>(
3119 f->glDrawElementsBaseVertex(psD->
drawMode,
3132 f->glDrawElementsInstancedBaseVertex(psD->
drawMode,
3139 f->glDrawElementsInstanced(psD->
drawMode,
3147 qWarning(
"No graphics pipeline active for drawIndexed; ignored");
3170 for (
int i = 1;
i < colorAttCount; ++
i)
3181 f->glDrawBuffers(
bufs.count(),
bufs.constData());
3191 f->glDisable(GL_SCISSOR_TEST);
3193 f->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3197 f->glDepthMask(GL_TRUE);
3201 f->glStencilMask(0xFF);
3242 f->glGenFramebuffers(1, &fbo);
3274 f->glDeleteFramebuffers(1, &fbo);
3288 f->glGenFramebuffers(1, &fbo);
3306 const int w =
result->pixelSize.width();
3307 const int h =
result->pixelSize.height();
3319 for (
int y = 0;
y <
h; ++
y) {
3323 while (
count-- > 0) {
3324 *
dst++ =
src[componentIndex];
3329 switch (
result->format) {
3357 f->glDeleteFramebuffers(1, &fbo);
3388 f->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
3400 glCompressedTexImage1D(
3420 glCompressedTexSubImage1D(
3438 f->glDisable(GL_SCISSOR_TEST);
3440 f->glGenFramebuffers(2, fbo);
3456 GL_COLOR_BUFFER_BIT,
3459 f->glDeleteFramebuffers(2, fbo);
3467 f->glDisable(GL_SCISSOR_TEST);
3469 f->glGenFramebuffers(2, fbo);
3492 GL_COLOR_BUFFER_BIT,
3495 f->glDeleteFramebuffers(2, fbo);
3535 f->glMemoryBarrier(barriers);
3546 if (
state.instancedAttributesUsed) {
3548 if (
state.nonzeroAttribDivisor[
i])
3549 f->glVertexAttribDivisor(
GLuint(
i), 0);
3552 f->glVertexAttribDivisor(
GLuint(
i), 0);
3564 state.scissor = scissor;
3566 f->glEnable(GL_SCISSOR_TEST);
3568 f->glDisable(GL_SCISSOR_TEST);
3574 state.cullFace = cullFace;
3575 state.cullMode = cullMode;
3577 f->glEnable(GL_CULL_FACE);
3578 f->glCullFace(cullMode);
3580 f->glDisable(GL_CULL_FACE);
3586 state.frontFace = frontFace;
3587 f->glFrontFace(frontFace);
3592 state.polygonMode = polygonMode;
3593 glPolygonMode(GL_FRONT_AND_BACK, polygonMode);
3612 state.colorMask = colorMask;
3613 f->glColorMask(colorMask.
r, colorMask.
g, colorMask.
b, colorMask.
a);
3616 const bool blendEnabled = targetBlend.
enable;
3626 state.blendEnabled = blendEnabled;
3628 state.blend = blend;
3629 f->glEnable(GL_BLEND);
3633 f->glDisable(GL_BLEND);
3639 state.colorMask = colorMask;
3640 f->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3642 const bool blendEnabled =
false;
3644 state.blendEnabled = blendEnabled;
3645 f->glDisable(GL_BLEND);
3651 state.depthTest = depthTest;
3653 f->glEnable(GL_DEPTH_TEST);
3655 f->glDisable(GL_DEPTH_TEST);
3660 state.depthWrite = depthWrite;
3661 f->glDepthMask(depthWrite);
3666 state.depthFunc = depthFunc;
3667 f->glDepthFunc(depthFunc);
3687 && (stencilReadMask !=
state.stencilReadMask || stencilWriteMask !=
state.stencilWriteMask
3688 || stencilFront !=
state.stencil[0] || stencilBack !=
state.stencil[1])))
3690 state.stencilTest = stencilTest;
3692 state.stencilReadMask = stencilReadMask;
3693 state.stencilWriteMask = stencilWriteMask;
3694 state.stencil[0] = stencilFront;
3695 state.stencil[1] = stencilBack;
3697 f->glEnable(GL_STENCIL_TEST);
3699 f->glStencilFuncSeparate(GL_FRONT, stencilFront.
func,
state.dynamic.stencilRef, stencilReadMask);
3701 f->glStencilMaskSeparate(GL_FRONT, stencilWriteMask);
3703 f->glStencilFuncSeparate(GL_BACK, stencilBack.
func,
state.dynamic.stencilRef, stencilReadMask);
3705 f->glStencilMaskSeparate(GL_BACK, stencilWriteMask);
3707 f->glDisable(GL_STENCIL_TEST);
3715 || polyOffsetFactor !=
state.polyOffsetFactor || polyOffsetUnits !=
state.polyOffsetUnits)
3717 state.polyOffsetFill = polyOffsetFill;
3718 state.polyOffsetFactor = polyOffsetFactor;
3719 state.polyOffsetUnits = polyOffsetUnits;
3720 if (polyOffsetFill) {
3721 f->glPolygonOffset(polyOffsetFactor, polyOffsetUnits);
3722 f->glEnable(GL_POLYGON_OFFSET_FILL);
3724 f->glDisable(GL_POLYGON_OFFSET_FILL);
3731 state.lineWidth = lineWidth;
3732 f->glLineWidth(lineWidth);
3739 state.cpCount = cpCount;
3747template <
typename T>
3750 const T *
p =
reinterpret_cast<const T *
>(
src);
3751 for (
int i = 0;
i < elemCount; ++
i) {
3752 for (
int j = 0;
j < vecSize; ++
j)
3753 dst[vecSize *
i +
j] = *
p++;
3759 void *ps,
uint psGeneration,
int glslLocation,
3760 int *texUnit,
bool *activeTexUnitAltered)
3762 const bool samplerStateValid = texD->
samplerState == samplerD->
d;
3763 const bool cachedStateInRange = *texUnit < 16;
3764 bool updateTextureBinding =
true;
3765 if (samplerStateValid && cachedStateInRange) {
3777 updateTextureBinding =
false;
3780 if (updateTextureBinding) {
3782 *activeTexUnitAltered =
true;
3784 f->glUniform1i(glslLocation, *texUnit);
3785 if (cachedStateInRange) {
3792 if (!samplerStateValid) {
3814 const uint *dynOfsPairs,
int dynOfsCount)
3818 bool activeTexUnitAltered =
false;
3828 struct SeparateTexture {
3834 struct SeparateSampler {
3846 int viewOffset =
b->u.ubuf.offset;
3847 for (
int j = 0;
j < dynOfsCount; ++
j) {
3848 if (dynOfsPairs[2 *
j] ==
uint(
b->binding)) {
3849 viewOffset = int(dynOfsPairs[2 *
j + 1]);
3856 if (uniform.binding ==
b->binding) {
3859 const void *
src = bufView + uniform.offset;
3862 if (uniform.arrayDim > 0
3874 qWarning(
"Uniform with buffer binding %d, buffer offset %d, type %d is an array, "
3875 "but arrays are only supported for float, vec2, vec3, vec4, int, "
3876 "ivec2, ivec3, ivec4, mat3 and mat4. "
3877 "Only the first element will be set.",
3878 uniform.binding, uniform.offset, uniform.type);
3888 switch (uniform.type) {
3891 const int elemCount = uniform.arrayDim;
3892 if (elemCount < 1) {
3893 const float v = *
reinterpret_cast<const float *
>(
src);
3898 thisUniformState.
v[0] =
v;
3899 f->glUniform1f(uniform.glslLocation,
v);
3902 f->glUniform1f(uniform.glslLocation,
v);
3906 packedArray.
resize(elemCount);
3908 f->glUniform1fv(uniform.glslLocation, elemCount, &packedArray.
constData()->f);
3914 const int elemCount = uniform.arrayDim;
3915 if (elemCount < 1) {
3916 const float *
v =
reinterpret_cast<const float *
>(
src);
3920 || thisUniformState.
v[0] !=
v[0]
3921 || thisUniformState.
v[1] !=
v[1])
3924 thisUniformState.
v[0] =
v[0];
3925 thisUniformState.
v[1] =
v[1];
3926 f->glUniform2fv(uniform.glslLocation, 1,
v);
3929 f->glUniform2fv(uniform.glslLocation, 1,
v);
3932 packedArray.
resize(elemCount * 2);
3934 f->glUniform2fv(uniform.glslLocation, elemCount, &packedArray.
constData()->f);
3940 const int elemCount = uniform.arrayDim;
3941 if (elemCount < 1) {
3942 const float *
v =
reinterpret_cast<const float *
>(
src);
3946 || thisUniformState.
v[0] !=
v[0]
3947 || thisUniformState.
v[1] !=
v[1]
3948 || thisUniformState.
v[2] !=
v[2])
3951 thisUniformState.
v[0] =
v[0];
3952 thisUniformState.
v[1] =
v[1];
3953 thisUniformState.
v[2] =
v[2];
3954 f->glUniform3fv(uniform.glslLocation, 1,
v);
3957 f->glUniform3fv(uniform.glslLocation, 1,
v);
3960 packedArray.
resize(elemCount * 3);
3962 f->glUniform3fv(uniform.glslLocation, elemCount, &packedArray.
constData()->f);
3968 const int elemCount = uniform.arrayDim;
3969 if (elemCount < 1) {
3970 const float *
v =
reinterpret_cast<const float *
>(
src);
3974 || thisUniformState.
v[0] !=
v[0]
3975 || thisUniformState.
v[1] !=
v[1]
3976 || thisUniformState.
v[2] !=
v[2]
3977 || thisUniformState.
v[3] !=
v[3])
3980 thisUniformState.
v[0] =
v[0];
3981 thisUniformState.
v[1] =
v[1];
3982 thisUniformState.
v[2] =
v[2];
3983 thisUniformState.
v[3] =
v[3];
3984 f->glUniform4fv(uniform.glslLocation, 1,
v);
3987 f->glUniform4fv(uniform.glslLocation, 1,
v);
3990 f->glUniform4fv(uniform.glslLocation, elemCount,
reinterpret_cast<const float *
>(
src));
3995 f->glUniformMatrix2fv(uniform.glslLocation, 1, GL_FALSE,
reinterpret_cast<const float *
>(
src));
3999 const int elemCount = uniform.arrayDim;
4000 if (elemCount < 1) {
4003 const float *srcMat =
reinterpret_cast<const float *
>(
src);
4004 memcpy(mat, srcMat, 3 *
sizeof(
float));
4005 memcpy(mat + 3, srcMat + 4, 3 *
sizeof(
float));
4006 memcpy(mat + 6, srcMat + 8, 3 *
sizeof(
float));
4007 f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, mat);
4009 packedArray.
resize(elemCount * 9);
4011 f->glUniformMatrix3fv(uniform.glslLocation, elemCount, GL_FALSE, &packedArray.
constData()->f);
4016 f->glUniformMatrix4fv(uniform.glslLocation,
qMax(1, uniform.arrayDim), GL_FALSE,
reinterpret_cast<const float *
>(
src));
4020 const int elemCount = uniform.arrayDim;
4021 if (elemCount < 1) {
4022 f->glUniform1i(uniform.glslLocation, *
reinterpret_cast<const qint32 *
>(
src));
4024 packedArray.
resize(elemCount);
4026 f->glUniform1iv(uniform.glslLocation, elemCount, &packedArray.
constData()->i);
4032 const int elemCount = uniform.arrayDim;
4033 if (elemCount < 1) {
4034 f->glUniform2iv(uniform.glslLocation, 1,
reinterpret_cast<const qint32 *
>(
src));
4036 packedArray.
resize(elemCount * 2);
4038 f->glUniform2iv(uniform.glslLocation, elemCount, &packedArray.
constData()->i);
4044 const int elemCount = uniform.arrayDim;
4045 if (elemCount < 1) {
4046 f->glUniform3iv(uniform.glslLocation, 1,
reinterpret_cast<const qint32 *
>(
src));
4048 packedArray.
resize(elemCount * 3);
4050 f->glUniform3iv(uniform.glslLocation, elemCount, &packedArray.
constData()->i);
4055 f->glUniform4iv(uniform.glslLocation,
qMax(1, uniform.arrayDim),
reinterpret_cast<const qint32 *
>(
src));
4058 f->glUniform1ui(uniform.glslLocation, *
reinterpret_cast<const quint32 *
>(
src));
4061 f->glUniform2uiv(uniform.glslLocation, 1,
reinterpret_cast<const quint32 *
>(
src));
4064 f->glUniform3uiv(uniform.glslLocation, 1,
reinterpret_cast<const quint32 *
>(
src));
4067 f->glUniform4uiv(uniform.glslLocation, 1,
reinterpret_cast<const quint32 *
>(
src));
4070 f->glUniform1i(uniform.glslLocation, *
reinterpret_cast<const qint32 *
>(
src));
4073 f->glUniform2iv(uniform.glslLocation, 1,
reinterpret_cast<const qint32 *
>(
src));
4076 f->glUniform3iv(uniform.glslLocation, 1,
reinterpret_cast<const qint32 *
>(
src));
4079 f->glUniform4iv(uniform.glslLocation, 1,
reinterpret_cast<const qint32 *
>(
src));
4082 qWarning(
"Uniform with buffer binding %d, buffer offset %d has unsupported type %d",
4083 uniform.binding, uniform.offset, uniform.type);
4096 if (maybeGraphicsPs) {
4097 ps = maybeGraphicsPs;
4100 ps = maybeComputePs;
4103 for (
int elem = 0; elem <
b->u.stex.count; ++elem) {
4107 if (shaderSampler.combinedBinding ==
b->binding) {
4108 const int loc = shaderSampler.glslLocation + elem;
4109 bindCombinedSampler(cbD, texD, samplerD, ps, psGeneration, loc, &texUnit, &activeTexUnitAltered);
4117 for (
int elem = 0; elem <
b->u.stex.count; ++elem) {
4119 separateTextureBindings.
append({ texD,
b->binding, elem });
4125 separateSamplerBindings.
append({ samplerD,
b->binding });
4151 if (
b->u.sbuf.offset == 0 &&
b->u.sbuf.maybeSize == 0)
4155 b->u.sbuf.offset,
b->u.sbuf.maybeSize ?
b->u.sbuf.maybeSize : bufD->
m_size);
4164 if (!separateTextureBindings.
isEmpty() || !separateSamplerBindings.
isEmpty()) {
4169 if (maybeGraphicsPs) {
4170 ps = maybeGraphicsPs;
4173 ps = maybeComputePs;
4177 if (shaderSampler.combinedBinding >= 0)
4179 for (
const SeparateSampler &sepSampler : separateSamplerBindings) {
4180 if (sepSampler.binding != shaderSampler.sbinding)
4182 for (
const SeparateTexture &sepTex : separateTextureBindings) {
4183 if (sepTex.binding != shaderSampler.tbinding)
4185 const int loc = shaderSampler.glslLocation + sepTex.elem;
4187 loc, &texUnit, &activeTexUnitAltered);
4193 if (activeTexUnitAltered)
4205 bool *wantsColorClear,
bool *wantsDsClear)
4219 if (wantsColorClear)
4220 *wantsColorClear = doClearBuffers && doClearColorBuffer;
4222 *wantsDsClear = doClearBuffers;
4233 if (wantsColorClear)
4288 const QColor &colorClearValue,
4291 QRhiCommandBuffer::BeginPassFlags
flags)
4296 if (resourceUpdates)
4305 if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QGles2Texture, QGles2RenderBuffer>(rtTex->
description(), rtTex->
d.
currentResIdList))
4309 bool wantsColorClear, wantsDsClear;
4318 clearCmd.
args.
clear.
mask |= GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
4352 qWarning(
"Resolve source (%dx%d) and target (%dx%d) size does not match",
4373 qWarning(
"Resolve source (%dx%d) and target (%dx%d) size does not match",
4377 for (
int resolveIdx = 0; resolveIdx < resolveCount; ++resolveIdx) {
4378 const int srcLayer = colorAtt.
layer() + resolveIdx;
4379 const int dstLayer = colorAtt.
resolveLayer() + resolveIdx;
4410 if (resourceUpdates)
4416 QRhiCommandBuffer::BeginPassFlags)
4421 if (resourceUpdates)
4438 if (resourceUpdates)
4449 if (pipelineChanged) {
4463 int loadTypeVal,
int storeTypeVal,
int loadStoreTypeVal)
4466 if (bindingType == loadTypeVal) {
4470 if (bindingType == loadStoreTypeVal)
4473 auto it = writtenResources->
find(resource);
4474 if (
it != writtenResources->
end())
4476 else if (bindingType == storeTypeVal || bindingType == loadStoreTypeVal)
4477 writtenResources->insert(resource, {
access,
true });
4492 accessAndIsNewFlag = { 0,
false };
4496 for (
int i = 0;
i < bindingCount; ++
i) {
4525 const int accessInThisDispatch =
it->first;
4526 const bool isNewInThisDispatch =
it->second;
4527 if (accessInThisDispatch && !isNewInThisDispatch) {
4583 versionsToTry << 320 << 310 << 300 << 100;
4585 versionsToTry << 310 << 300 << 100;
4587 versionsToTry << 300 << 100;
4589 versionsToTry << 100;
4591 for (
int v : versionsToTry) {
4596 *shaderVersion = ver;
4602 versionsToTry << 460 << 450 << 440 << 430 << 420 << 410 << 400 << 330 << 150 << 140 << 130;
4604 versionsToTry << 450 << 440 << 430 << 420 << 410 << 400 << 330 << 150 << 140 << 130;
4606 versionsToTry << 440 << 430 << 420 << 410 << 400 << 330 << 150 << 140 << 130;
4608 versionsToTry << 430 << 420 << 410 << 400 << 330 << 150 << 140 << 130;
4610 versionsToTry << 420 << 410 << 400 << 330 << 150 << 140 << 130;
4612 versionsToTry << 410 << 400 << 330 << 150 << 140 << 130;
4614 versionsToTry << 400 << 330 << 150 << 140 << 130;
4616 versionsToTry << 330 << 150 << 140 << 130;
4618 versionsToTry << 150 << 140 << 130;
4620 versionsToTry << 140 << 130;
4622 versionsToTry << 130;
4625 versionsToTry << 120;
4626 for (
int v : versionsToTry) {
4636 qWarning() <<
"No GLSL shader code found (versions tried: " << versionsToTry
4637 <<
") in baked shader" << bakedShader;
4654 const char *srcStr =
source.constData();
4656 f->glShaderSource(
shader, 1, &srcStr, &srcLength);
4661 GLint infoLogLength = 0;
4664 if (infoLogLength > 1) {
4666 log.
resize(infoLogLength);
4692 GLint infoLogLength = 0;
4695 if (infoLogLength > 1) {
4697 log.
resize(infoLogLength);
4715 qWarning(
"Nested structs are not supported at the moment. '%s' ignored.",
4729 if (
var.arrayDims.size() > 1) {
4730 qWarning(
"Array '%s' has more than one dimension. This is not supported.",
4737 uniform.
arrayDim =
var.arrayDims.isEmpty() ? 0 :
var.arrayDims.first();
4738 dst->append(uniform);
4750 QByteArray structPrefix = prefix + blockMember.name;
4752 const int baseOffset = blockMember.offset;
4753 if (blockMember.arrayDims.isEmpty()) {
4756 baseOffset,
program, activeUniformLocations,
dst);
4758 if (blockMember.arrayDims.size() > 1) {
4759 qWarning(
"Array of struct '%s' has more than one dimension. Only the first "
4760 "dimension is used.",
4761 blockMember.name.constData());
4763 const int dim = blockMember.arrayDims.first();
4764 const int elemSize = blockMember.size / dim;
4765 int elemOffset = baseOffset;
4766 for (
int di = 0; di < dim; ++di) {
4770 elemOffset += elemSize;
4784 sampler.glslLocation =
f->glGetUniformLocation(
program,
v.name.constData());
4785 if (
sampler.glslLocation >= 0) {
4786 sampler.combinedBinding =
v.binding;
4799 if (
sampler.glslLocation >= 0) {
4818 if (inVar.location == outVar.location) {
4819 if (inVar.name != outVar.name) {
4820 qWarning(
"Vertex output name '%s' does not match fragment input '%s'. "
4821 "This should be avoided because it causes problems with older GLSL versions.",
4822 outVar.name.constData(), inVar.name.constData());
4873 if (legacyDiskCacheEnabled || pipelineCacheEnabled) {
4875 for (
int i = 0;
i < stageCount; ++
i) {
4912 *cacheKey = binaryProgram.
cacheKey();
4917 if (pipelineCacheEnabled) {
4922 err =
f->glGetError();
4927 err =
f->glGetError();
4928 if (err == GL_NO_ERROR) {
4929 GLint linkStatus = 0;
4931 if (linkStatus == GL_TRUE)
4937 if (legacyDiskCacheEnabled && qrhi_programBinaryCache()->
load(*cacheKey,
program)) {
4939 qCDebug(lcOpenGLProgramDiskCache,
"Program binary received from cache, program %u, key %s",
4954 qCDebug(lcOpenGLProgramDiskCache,
"Saving program binary, program %u, key %s",
4956 qrhi_programBinaryCache()->save(cacheKey,
program);
4972 if (blobSize == outSize)
5001 rhiD->releaseQueue.append(
e);
5002 rhiD->unregisterResource(
this);
5017 qWarning(
"Uniform buffer: multiple usages specified, this is not supported by the OpenGL backend");
5024 if (!rhiD->ensureContext())
5033 rhiD->f->glGenBuffers(1, &
buffer);
5039 rhiD->registerResource(
this);
5048 return { { &
buffer }, 1 };
5057 if (rhiD->caps.properMapBuffer) {
5073 if (rhiD->caps.properMapBuffer)
5081 int sampleCount, QRhiRenderBuffer::Flags
flags,
5109 rhiD->releaseQueue.append(
e);
5110 rhiD->unregisterResource(
this);
5126 qWarning(
"RenderBuffer: UsedWithSwapChainOnly is meaningless in combination with Color");
5129 if (!rhiD->ensureContext())
5139 if (rhiD->caps.msaaRenderBuffer &&
samples > 1) {
5143 }
else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) {
5149 GLenum depthStorage = GL_DEPTH_COMPONENT;
5150 if (rhiD->caps.gles) {
5151 if (rhiD->caps.depth24)
5168 if (rhiD->caps.rgba8Format) {
5171 GLenum glintformat, glformat, gltype;
5177 if (rhiD->caps.msaaRenderBuffer &&
samples > 1) {
5193 rhiD->registerResource(
this);
5209 qWarning(
"RenderBuffer: UsedWithSwapChainOnly is meaningless when importing an existing native object");
5211 if (!rhiD->ensureContext())
5218 rhiD->registerResource(
this);
5258 rhiD->releaseQueue.append(
e);
5259 rhiD->unregisterResource(
this);
5269 if (!rhiD->ensureContext())
5276 const bool isCompressed = rhiD->isCompressedFormat(
m_format);
5282 if (is3D && !rhiD->caps.texture3D) {
5283 qWarning(
"3D textures are not supported");
5286 if (isCube && is3D) {
5287 qWarning(
"Texture cannot be both cube and 3D");
5290 if (isArray && is3D) {
5291 qWarning(
"Texture cannot be both array and 3D");
5294 if (is1D && !rhiD->caps.texture1D) {
5295 qWarning(
"1D textures are not supported");
5299 qWarning(
"Texture cannot be both 1D and 3D");
5302 if (is1D && isCube) {
5303 qWarning(
"Texture cannot be both 1D and cube");
5308 qWarning(
"Texture cannot have a depth of %d when it is not 3D",
m_depth);
5336 qWarning(
"Compressed texture cannot be used with image load/store");
5341 qWarning(
"Compressed format %d not mappable to GL compressed format",
m_format);
5356 *adjustedSize =
size;
5368 rhiD->f->glGenTextures(1, &
texture);
5374 const bool isCompressed = rhiD->isCompressedFormat(
m_format);
5377 if (!isCompressed) {
5390 }
else if (is3D || isArray) {
5402 }
else if (hasMipMaps || isCube) {
5404 for (
int layer = 0, layerCount = isCube ? 6 : 1;
layer != layerCount; ++
layer) {
5420 if (is1D && !isArray)
5422 else if (!is1D && (is3D || isArray))
5440 rhiD->registerResource(
this);
5461 rhiD->registerResource(
this);
5472 :
QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u,
v,
w)
5485 rhiD->unregisterResource(
this);
5499 rhiD->registerResource(
this,
false);
5518 rhiD->unregisterResource(
this);
5531 rhiD->registerResource(rpD,
false);
5598 rhiD->releaseQueue.append(
e);
5599 rhiD->unregisterResource(
this);
5607 rhiD->registerResource(rpD,
false);
5623 if (hasColorAttachments) {
5625 if (
count > rhiD->caps.maxDrawBuffers) {
5626 qWarning(
"QGles2TextureRenderTarget: Too many color attachments (%d, max is %d)",
5627 count, rhiD->caps.maxDrawBuffers);
5631 qWarning(
"QGles2TextureRenderTarget: Depth texture is not supported and will be ignored");
5633 if (!rhiD->ensureContext())
5641 int multiViewCount = 0;
5669 if (attIndex == 0) {
5673 }
else if (renderBuffer) {
5676 if (attIndex == 0) {
5683 if (hasDepthStencil) {
5686 if (rhiD->caps.needsDepthStencilCombinedAttach) {
5705 if (multiViewCount < 2) {
5715 0, 0, multiViewCount);
5716 if (rhiD->isStencilSupportingFormat(depthTexD->
format())) {
5718 0, 0, multiViewCount);
5736 qWarning(
"Framebuffer incomplete: 0x%x", status);
5740 QRhiRenderTargetAttachmentTracker::updateResIdList<QGles2Texture, QGles2RenderBuffer>(
m_desc, &
d.
currentResIdList);
5742 rhiD->registerResource(
this);
5748 if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QGles2Texture, QGles2RenderBuffer>(
m_desc,
d.
currentResIdList))
5778 rhiD->unregisterResource(
this);
5784 if (!rhiD->sanityCheckShaderResourceBindings(
this))
5791 if (
b->u.ubuf.hasDynamicOffset) {
5798 rhiD->updateLayoutDesc(
this);
5801 rhiD->registerResource(
this,
false);
5837 rhiD->releaseQueue.append(
e);
5838 rhiD->unregisterResource(
this);
5859 if (!rhiD->ensureContext())
5862 rhiD->pipelineCreationStart();
5863 if (!rhiD->sanityCheckGraphicsPipeline(
this))
5868 program = rhiD->f->glCreateProgram();
5879 switch (shaderStage.type()) {
5893 Q_UNREACHABLE_RETURN(VtxIdx);
5897 bool vertexFragmentOnly =
true;
5900 const int idx = descIdxForStage(shaderStage);
5901 if (idx != VtxIdx && idx != FragIdx)
5902 vertexFragmentOnly =
false;
5906 if (!rhiD->shaderSource(shaderStage, &shaderVersion).isEmpty()) {
5907 samplerMappingList[idx] =
shader.separateToCombinedImageSamplerMappingList(
5917 desc[VtxIdx].inputVariables(),
5925 if (!rhiD->compileShader(
program, shaderStage,
nullptr))
5932 rhiD->f->glBindAttribLocation(
program,
GLuint(inVar.location), inVar.name);
5934 if (vertexFragmentOnly)
5935 rhiD->sanityCheckVertexFragmentInterface(
desc[VtxIdx],
desc[FragIdx]);
5937 if (!rhiD->linkProgram(
program))
5943 rhiD->trySaveToPipelineCache(
program, cacheKey,
true);
5947 rhiD->trySaveToDiskCache(
program, cacheKey);
5954 rhiD->trySaveToPipelineCache(
program, cacheKey);
5965 const int idx = descIdxForStage(shaderStage);
5967 rhiD->gatherUniforms(
program, ub, &activeUniformLocations, &
uniforms);
5978 return a.offset < b.offset;
5986 rhiD->pipelineCreationEnd();
5988 rhiD->registerResource(
this);
6018 rhiD->releaseQueue.append(
e);
6019 rhiD->unregisterResource(
this);
6030 if (!rhiD->ensureContext())
6033 rhiD->pipelineCreationStart();
6038 if (!rhiD->shaderSource(
m_shaderStage, &shaderVersion).isEmpty()) {
6043 program = rhiD->f->glCreateProgram();
6054 if (!rhiD->linkProgram(
program))
6060 rhiD->trySaveToPipelineCache(
program, cacheKey,
true);
6064 rhiD->trySaveToDiskCache(
program, cacheKey);
6071 rhiD->trySaveToPipelineCache(
program, cacheKey);
6077 rhiD->gatherUniforms(
program, ub, &activeUniformLocations, &
uniforms);
6090 rhiD->pipelineCreationEnd();
6092 rhiD->registerResource(
this);
6130 rhiD->unregisterResource(
this);
6150 Q_UNREACHABLE_RETURN(
nullptr);
6168 rhiD->registerResource(rpD,
false);
6216 if (needsRegistration) {
6218 rhiD->registerResource(
this,
false);
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
The QColor class provides colors based on RGB, HSV or CMYK values.
float greenF() const noexcept
Returns the green color component of this color.
float redF() const noexcept
Returns the red color component of this color.
float alphaF() const noexcept
Returns the alpha color component of this color.
float blueF() const noexcept
Returns the blue color component of this color.
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
qsizetype size() const noexcept
Returns the number of items in the hash.
const_iterator constFind(const Key &key) const noexcept
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
iterator erase(const_iterator it)
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
bool isEmpty() const noexcept
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
const_iterator cend() const
const_iterator cbegin() const
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void setFormat(const QSurfaceFormat &format)
Sets the offscreen surface format.
bool create()
Attempts to create the OpenGL context with the current configuration.
QSurfaceFormat format() const
Returns the format of the underlying platform context, if create() has been called.
QOpenGLContext * shareContext() const
Returns the share context this context was created with.
void setFormat(const QSurfaceFormat &format)
Sets the format the OpenGL context should be compatible with.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QScreen * screen() const
Returns the screen the context was created for.
QOpenGLProgramBinarySupportCheck * get(QOpenGLContext *context)
\inmodule QtCore\reentrant
constexpr bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
const char * constData() const
Type
Specifies storage type of buffer resource.
QRhiRenderBuffer * renderBuffer() const
int multiViewCount() const
QRhiTexture * texture() const
QRhiTexture * resolveTexture() const
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
@ DoNotTrackResourcesForCompute
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
IndexFormat
Specifies the index data type.
QRhiShaderStage m_shaderStage
QRhiShaderResourceBindings * m_shaderResourceBindings
float depthClearValue() const
quint32 stencilClearValue() const
\variable QRhiGles2InitParams::format
QHash< QRhiShaderStage, uint > m_shaderCache
QRhiStats statistics() override
void gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, QDuplicateTracker< int, 256 > *activeUniformLocations, QGles2UniformDescriptionVector *dst)
void registerUniformIfActive(const QShaderDescription::BlockVariable &var, const QByteArray &namePrefix, int binding, int baseOffset, GLuint program, QDuplicateTracker< int, 256 > *activeUniformLocations, QGles2UniformDescriptionVector *dst)
const GLvoid const GLvoid GLuint
void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) override
QOpenGLContext * maybeShareContext
void trackedBufferBarrier(QGles2CommandBuffer *cbD, QGles2Buffer *bufD, QGles2Buffer::Access access)
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override
void enqueueBarriersForPass(QGles2CommandBuffer *cbD)
QList< DeferredReleaseEntry > releaseQueue
int resourceLimit(QRhi::ResourceLimit limit) const override
void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat) override
bool isFeatureSupported(QRhi::Feature feature) const override
QRhiGraphicsPipeline * createGraphicsPipeline() override
void bindShaderResources(QGles2CommandBuffer *cbD, QRhiGraphicsPipeline *maybeGraphicsPs, QRhiComputePipeline *maybeComputePs, QRhiShaderResourceBindings *srb, const uint *dynOfsPairs, int dynOfsCount)
bool create(QRhi::Flags flags) override
void trackedRegisterTexture(QRhiPassResourceTracker *passResTracker, QGles2Texture *texD, QRhiPassResourceTracker::TextureAccess access, QRhiPassResourceTracker::TextureStage stage)
void executeBindGraphicsPipeline(QGles2CommandBuffer *cbD, QGles2GraphicsPipeline *psD)
QRhiDriverInfo driverInfo() const override
QSurfaceFormat requestedFormat
QHash< QByteArray, PipelineCacheData > m_pipelineCache
bool isProgramBinaryDiskCacheEnabled() const
bool needsMakeCurrentDueToSwap
void trackedImageBarrier(QGles2CommandBuffer *cbD, QGles2Texture *texD, QGles2Texture::Access access)
void trackedRegisterBuffer(QRhiPassResourceTracker *passResTracker, QGles2Buffer *bufD, QRhiPassResourceTracker::BufferAccess access, QRhiPassResourceTracker::BufferStage stage)
QRhiComputePipeline * createComputePipeline() override
QRhiDriverInfo driverInfoStruct
QSurface * evaluateFallbackSurface() const
void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
void sanityCheckVertexFragmentInterface(const QShaderDescription &vsDesc, const QShaderDescription &fsDesc)
QRhiGles2NativeHandles nativeHandlesStruct
QMatrix4x4 clipSpaceCorrMatrix() const override
QRhi::FrameOpResult finish() override
void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override
QList< int > supportedSampleCounts() const override
int effectiveSampleCount(int sampleCount) const
void gatherSamplers(GLuint program, const QShaderDescription::InOutVariable &v, QGles2SamplerDescriptionVector *dst)
QSet< GLint > supportedCompressedFormats
QRhiSwapChain * createSwapChain() override
void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override
QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint) override
void executeCommandBuffer(QRhiCommandBuffer *cb)
void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps) override
QSurface * fallbackSurface
QRhiGles2(QRhiGles2InitParams *params, QRhiGles2NativeHandles *importDevice=nullptr)
void trySaveToDiskCache(GLuint program, const QByteArray &cacheKey)
struct QRhiGles2::Caps caps
bool compileShader(GLuint program, const QRhiShaderStage &shaderStage, QShaderVersion *shaderVersion)
QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags) override
void bindCombinedSampler(QGles2CommandBuffer *cbD, QGles2Texture *texD, QGles2Sampler *samplerD, void *ps, uint psGeneration, int glslLocation, int *texUnit, bool *activeTexUnitAltered)
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override
QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags) override
QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w) override
void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
QGles2SwapChain * currentSwapChain
bool isDeviceLost() const override
QRhiShaderResourceBindings * createShaderResourceBindings() override
bool isYUpInNDC() const override
void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override
void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
bool makeThreadLocalNativeContextCurrent() override
int ubufAlignment() const override
void beginExternal(QRhiCommandBuffer *cb) override
void endExternal(QRhiCommandBuffer *cb) override
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override
QByteArray shaderSource(const QRhiShaderStage &shaderStage, QShaderVersion *shaderVersion)
QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size) override
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override
void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override
bool ensureContext(QSurface *surface=nullptr) const
void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override
void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
ProgramCacheResult tryLoadFromDiskOrPipelineCache(const QRhiShaderStage *stages, int stageCount, GLuint program, const QVector< QShaderDescription::InOutVariable > &inputVars, QByteArray *cacheKey)
void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
bool isYUpInFramebuffer() const override
bool linkProgram(GLuint program)
void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override
QGles2RenderTargetData * enqueueBindFramebuffer(QRhiRenderTarget *rt, QGles2CommandBuffer *cbD, bool *wantsColorClear=nullptr, bool *wantsDsClear=nullptr)
void debugMarkEnd(QRhiCommandBuffer *cb) override
void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override
void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override
void releaseCachedResources() override
bool isClipDepthZeroToOne() const override
void trySaveToPipelineCache(GLuint program, const QByteArray &cacheKey, bool force=false)
void executeDeferredReleases()
QByteArray pipelineCacheData() override
double lastCompletedGpuTime(QRhiCommandBuffer *cb) override
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override
QList< int > supportedSampleCountList
QPointer< QWindow > maybeWindow
void enqueueSubresUpload(QGles2Texture *texD, QGles2CommandBuffer *cbD, int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc)
struct QRhiGles2::OffscreenFrame ofr
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override
void setPipelineCacheData(const QByteArray &data) override
QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override
void gatherGeneratedSamplers(GLuint program, const QShader::SeparateToCombinedImageSamplerMapping &mapping, QGles2SamplerDescriptionVector *dst)
const QRhiNativeHandles * nativeHandles() override
quint32 m_stencilReadMask
BlendOp
Specifies the blend operation.
PolygonMode
Specifies the polygon rasterization mode.
FrontFace
Specifies the front face winding order.
BlendFactor
Specifies the blend factor.
StencilOpState m_stencilFront
quint32 m_stencilWriteMask
CompareOp
Specifies the depth or stencil comparison function.
CullMode
Specifies the culling mode.
QVarLengthArray< QRhiShaderStage, 4 > m_shaderStages
QRhiVertexInputLayout m_vertexInputLayout
QVarLengthArray< TargetBlend, 8 > m_targetBlends
QRhiShaderResourceBindings * m_shaderResourceBindings
PolygonMode m_polygonMode
float m_slopeScaledDepthBias
Topology
Specifies the primitive topology.
StencilOpState m_stencilBack
StencilOp
Specifies the stencil operation.
int m_patchControlPointCount
bool isCompressedFormat(QRhiTexture::Format format) const
static const QRhiShaderResourceBinding::Data * shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
quint32 pipelineCacheRhiId() const
void compressedFormatInfo(QRhiTexture::Format format, const QSize &size, quint32 *bpl, quint32 *byteSize, QSize *blockDim) const
static const int MAX_SHADER_CACHE_ENTRIES
qint64 totalPipelineCreationTime() const
void textureFormatInfo(QRhiTexture::Format format, const QSize &size, quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const
static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages)
TextureIterator cendTextures() const
static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages)
BufferIterator cbeginBuffers() const
BufferIterator cendBuffers() const
TextureIterator cbeginTextures() const
void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, const UsageState &state)
void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, const UsageState &state)
QRhiTexture * texture() const
void setPixelSize(const QSize &sz)
Sets the size (in pixels) to sz.
QRhiTexture::Format m_backingFormatHint
Type
Specifies the type of the renderbuffer.
virtual bool create()=0
Creates the corresponding native graphics resources.
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Sets the QRhiRenderPassDescriptor desc for use with this render target.
QRhiRenderPassDescriptor * m_renderPassDesc
QVarLengthArray< BufferOp, BUFFER_OPS_STATIC_ALLOC > bufferOps
QVarLengthArray< TextureOp, TEXTURE_OPS_STATIC_ALLOC > textureOps
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
virtual Type resourceType() const =0
QRhiImplementation * m_rhi
Filter
Specifies the minification, magnification, or mipmap filtering.
AddressMode
Specifies the addressing mode.
CompareOp
Specifies the texture comparison function.
std::array< int, 4 > scissor() const
Type
Specifies type of the shader resource bound to a binding point.
QVarLengthArray< QRhiShaderResourceBinding, BINDING_PREALLOC > m_bindings
QShader::Variant shaderVariant() const
Type
Specifies the type of the shader stage.
QRhiRenderPassDescriptor * m_renderPassDesc
Format
Describes the swapchain format.
StereoTargetBuffer
Selects the backbuffer to use with a stereoscopic swapchain.
QRhiRenderBuffer * m_depthStencil
QPoint destinationTopLeft() const
QPoint sourceTopLeft() const
int destinationLevel() const
int destinationLayer() const
const QRhiColorAttachment * cbeginColorAttachments() const
QRhiTexture * depthTexture() const
const QRhiColorAttachment * cendColorAttachments() const
QRhiRenderBuffer * depthStencilBuffer() const
qsizetype colorAttachmentCount() const
QRhiTextureRenderTargetDescription m_desc
@ PreserveDepthStencilContents
QRhiTextureRenderTargetDescription description() const
quint32 dataStride() const
QPoint sourceTopLeft() const
QPoint destinationTopLeft() const
Format
Specifies the texture format.
ResourceLimit
Describes the resource limit to query.
@ MaxThreadsPerThreadGroup
@ MaxThreadGroupsPerDimension
Feature
Flag values to indicate what features are supported by the backend currently in use.
@ NonDynamicUniformBuffers
@ RenderToNonBaseMipLevel
@ MultisampleRenderBuffer
@ PipelineCacheDataLoadSave
@ ReadBackNonUniformBuffer
@ RenderToOneDimensionalTexture
@ OneDimensionalTextureMipmaps
@ ReadBackNonBaseMipLevel
@ ThreeDimensionalTextureMipmaps
@ NonFourAlignedEffectiveIndexBufferOffset
@ ThreeDimensionalTextures
@ ReadBackAnyTextureFormat
static const int MAX_MIP_LEVELS
FrameOpResult
Describes the result of operations that can have a soft failure.
@ EnablePipelineCacheDataSave
iterator find(const T &value)
bool contains(const T &value) const
iterator insert(const T &value)
QList< InOutVariable > inputVariables() const
QList< InOutVariable > outputVariables() const
QList< InOutVariable > combinedImageSamplers() const
QList< UniformBlock > uniformBlocks() const
SeparateToCombinedImageSamplerMappingList separateToCombinedImageSamplerMappingList(const QShaderKey &key) const
\variable QShader::SeparateToCombinedImageSamplerMapping::combinedSamplerName
QShaderCode shader(const QShaderKey &key) const
QShaderDescription description() const
Stage
Describes the stage of the graphics pipeline the shader is suitable for.
@ TessellationEvaluationStage
@ TessellationControlStage
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
SurfaceClass surfaceClass() const
Returns the surface class of this surface.
virtual QPlatformSurface * surfaceHandle() const =0
Returns a handle to the platform-specific implementation of the surface.
constexpr size_type size() const noexcept
const T & at(qsizetype idx) const
void resize(qsizetype sz)
const T * constData() const
iterator begin() noexcept
const void * constData() const
QSurfaceFormat format() const override
Returns the actual format of this window.
QSize size() const override
Returns the size of the window excluding any window frame.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
#define Q_STATIC_ASSERT(Condition)
#define QByteArrayLiteral(str)
static QString header(const QString &name)
static bool isCubeMap(const DDSHeader &dds)
static const qint64 headerSize
bool qFuzzyIsNull(qfloat16 f) noexcept
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
#define QOPENGLF_APIENTRYP
QOpenGLContext * qt_gl_global_share_context()
GLboolean GLboolean GLboolean b
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLenum GLint components
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
const void GLsizei GLsizei stride
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLenum GLuint GLenum GLsizei const GLchar * buf
#define GL_TEXTURE_2D_MULTISAMPLE
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLsizei GLsizei GLenum * binaryFormat
#define GL_TEXTURE_2D_ARRAY
#define GL_TEXTURE_EXTERNAL_OES
GLint GLsizei GLsizei GLenum format
GLsizei GLenum internalFormat
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
#define GL_NUM_PROGRAM_BINARY_FORMATS
#define GL_MIRRORED_REPEAT
#define GL_TEXTURE_COMPARE_FUNC
#define GL_MAX_VARYING_VECTORS
#define GL_MAX_COMPUTE_WORK_GROUP_COUNT
#define GL_FRAGMENT_SHADER
#define GL_TEXTURE_WRAP_R
#define GL_DEPTH24_STENCIL8
#define GL_DEPTH_COMPONENT16
#define GL_TEXTURE_CUBE_MAP
#define GL_PRIMITIVE_RESTART_FIXED_INDEX
#define GL_ONE_MINUS_CONSTANT_ALPHA
#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
#define GL_COMPRESSED_TEXTURE_FORMATS
#define GL_CONSTANT_COLOR
#define GL_FRAMEBUFFER_SRGB
#define GL_MAX_VERTEX_OUTPUT_COMPONENTS
#define GL_COLOR_ATTACHMENT0
#define GL_DEPTH_STENCIL_ATTACHMENT
#define GL_TEXTURE_CUBE_MAP_SEAMLESS
#define GL_COMPARE_REF_TO_TEXTURE
#define GL_SHADER_STORAGE_BUFFER
#define GL_ALL_BARRIER_BITS
#define GL_MAX_VERTEX_ATTRIBS
#define GL_STENCIL_INDEX8
#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS
typedef GLbitfield(APIENTRYP PFNGLQUERYMATRIXXOESPROC)(GLfixed *mantissa
#define GL_FRAMEBUFFER_COMPLETE
#define GL_MAX_COMPUTE_WORK_GROUP_SIZE
#define GL_VERTEX_PROGRAM_POINT_SIZE
#define GL_DRAW_FRAMEBUFFER
#define GL_PROGRAM_BINARY_LENGTH
#define GL_FUNC_REVERSE_SUBTRACT
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS
#define GL_TEXTURE_RECTANGLE
#define GL_TEXTURE_1D_ARRAY
#define GL_COMPILE_STATUS
GLdouble GLdouble GLdouble GLdouble q
#define GL_MAX_DRAW_BUFFERS
GLenum GLenum GLenum GLenum mapping
#define GL_MAX_ARRAY_TEXTURE_LAYERS
#define GL_CONSTANT_ALPHA
#define GL_ONE_MINUS_CONSTANT_COLOR
#define GL_MAX_VERTEX_UNIFORM_VECTORS
#define GL_READ_FRAMEBUFFER
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS
#define GL_DEPTH_ATTACHMENT
#define GL_SHADER_STORAGE_BARRIER_BIT
#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS
#define GL_ELEMENT_ARRAY_BUFFER
#define GL_DEPTH_COMPONENT24
#define GL_PATCH_VERTICES
#define GL_MAX_VERTEX_UNIFORM_COMPONENTS
#define GL_INFO_LOG_LENGTH
#define GL_STENCIL_ATTACHMENT
#define GL_MAX_VARYING_COMPONENTS
#define GL_MAX_VARYING_FLOATS
#define GL_TEXTURE_COMPARE_MODE
GLsizeiptr const void GLenum usage
static void normalize(double &x, double &y)
void forceUpdate(QQuickItem *item)
static GLenum toGlMinFilter(QRhiSampler::Filter f, QRhiSampler::Filter m)
static QGles2Buffer::Access toGlAccess(QRhiPassResourceTracker::BufferAccess access)
static GLenum toGlCompressedTextureFormat(QRhiTexture::Format format, QRhiTexture::Flags flags)
#define GL_DEPTH_COMPONENT32F
static GLenum toGlTextureCompareFunc(QRhiSampler::CompareOp op)
#define GL_GEOMETRY_SHADER
static GLenum toGlCompareOp(QRhiGraphicsPipeline::CompareOp op)
#define GL_DEPTH24_STENCIL8
#define GL_DEPTH_COMPONENT16
static GLenum toGlWrapMode(QRhiSampler::AddressMode m)
static GLenum toGlBlendFactor(QRhiGraphicsPipeline::BlendFactor f)
#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
static GLbitfield barriersForTexture()
#define GL_TESS_CONTROL_SHADER
static GLenum toGlFrontFace(QRhiGraphicsPipeline::FrontFace f)
#define GL_BGRA
\variable QRhiGles2NativeHandles::context
#define GL_UNIFORM_BARRIER_BIT
static void addBoundaryCommand(QGles2CommandBuffer *cbD, QGles2CommandBuffer::Command::Cmd type)
#define GL_ELEMENT_ARRAY_BARRIER_BIT
#define GL_TEXTURE_FETCH_BARRIER_BIT
#define GL_UNSIGNED_INT_24_8
#define GL_COMPUTE_SHADER
static QRhiPassResourceTracker::UsageState toPassTrackerUsageState(const QGles2Buffer::UsageState &bufUsage)
static bool bufferAccessIsWrite(QGles2Buffer::Access access)
static bool isGraphicsStage(const QRhiShaderStage &shaderStage)
static QShader::Stage toShaderStage(QRhiShaderStage::Type type)
static GLenum toGlBlendOp(QRhiGraphicsPipeline::BlendOp op)
#define GL_TESS_EVALUATION_SHADER
#define GL_PIXEL_BUFFER_BARRIER_BIT
static void toGlTextureFormat(QRhiTexture::Format format, const QRhiGles2::Caps &caps, GLenum *glintformat, GLenum *glsizedintformat, GLenum *glformat, GLenum *gltype)
#define GL_TEXTURE_UPDATE_BARRIER_BIT
static GLenum toGlShaderType(QRhiShaderStage::Type type)
#define GL_BUFFER_UPDATE_BARRIER_BIT
static GLenum toGlCullMode(QRhiGraphicsPipeline::CullMode c)
static GLenum toGlStencilOp(QRhiGraphicsPipeline::StencilOp op)
static GLbitfield barriersForBuffer()
static GLenum toGlTopology(QRhiGraphicsPipeline::Topology t)
#define GL_SHADER_STORAGE_BARRIER_BIT
void qrhigl_accumulateComputeResource(T *writtenResources, QRhiResource *resource, QRhiShaderResourceBinding::Type bindingType, int loadTypeVal, int storeTypeVal, int loadStoreTypeVal)
static void bindVertexIndexBufferWithStateReset(CommandBufferExecTrackedState *state, QOpenGLExtensions *f, GLenum target, GLuint buffer)
#define GL_DEPTH_COMPONENT24
static bool textureAccessIsWrite(QGles2Texture::Access access)
static GLenum toGlMagFilter(QRhiSampler::Filter f)
#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT
#define GL_FRAMEBUFFER_BARRIER_BIT
static void qrhi_std140_to_packed(T *dst, int vecSize, int elemCount, const void *src)
#define GL_UNSIGNED_INT_2_10_10_10_REV
static GLenum toGlPolygonMode(QRhiGraphicsPipeline::PolygonMode mode)
static QSurface * currentSurfaceForCurrentContext(QOpenGLContext *ctx)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
QVideoFrameFormat::PixelFormat fmt
view viewport() -> scroll(dx, dy, deviceRect)
QSvgRenderer * renderer
[0]
struct CommandBufferExecTrackedState::@353 lastBindVertexBuffer
bool nonzeroAttribDivisor[TRACKED_ATTRIB_COUNT]
GLuint currentArrayBuffer
GLuint currentElementArrayBuffer
int maxUntrackedInstancedAttribute
bool instancedAttributesUsed
static const int TRACKED_ATTRIB_COUNT
QRhiGraphicsPipeline * ps
bool enabledAttribArrays[TRACKED_ATTRIB_COUNT]
QGles2Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
char * beginFullDynamicBufferUpdateForCurrentFrame() override
void endFullDynamicBufferUpdateForCurrentFrame() override
To be called when the entire contents of the buffer data has been updated in the memory block returne...
QRhiBuffer::NativeBuffer nativeBuffer() override
bool create() override
Creates the corresponding native graphics resources.
union QGles2CommandBuffer::Command::Args args
QHash< QRhiResource *, QPair< int, bool > > writtenResources
struct QGles2CommandBuffer::GraphicsPassState::@357 dynamic
struct QGles2CommandBuffer::ComputePassState computePassState
QRhiShaderResourceBindings * currentGraphicsSrb
uint currentPipelineGeneration
int currentPassResTrackerIndex
uint currentSrbGeneration
static const int MAX_DYNAMIC_OFFSET_COUNT
struct QGles2CommandBuffer::GraphicsPassState graphicsPassState
QRhiBackendCommandList< Command > commands
QRhiComputePipeline * currentComputePipeline
QRhiRenderTarget * currentTarget
QRhiShaderResourceBindings * currentComputeSrb
QVarLengthArray< QRhiPassResourceTracker, 8 > passResTrackers
bool passNeedsResourceTracking
QGles2CommandBuffer(QRhiImplementation *rhi)
const void * retainImage(const QImage &image)
const void * retainData(const QByteArray &data)
const uchar * retainBufferData(const QRhiBufferData &data)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
struct QGles2CommandBuffer::TextureUnitState textureUnitState[16]
QRhiGraphicsPipeline * currentGraphicsPipeline
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION+1]
QGles2UniformDescriptionVector uniforms
QRhiShaderResourceBindings * currentSrb
QGles2ComputePipeline(QRhiImplementation *rhi)
uint currentSrbGeneration
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
bool create() override
Creates the corresponding native graphics resources.
QGles2GraphicsPipeline(QRhiImplementation *rhi)
~QGles2GraphicsPipeline()
QRhiShaderResourceBindings * currentSrb
uint currentSrbGeneration
QGles2UniformDescriptionVector uniforms
QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION+1]
bool create() override
Creates the corresponding native graphics resources.
QGles2RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)
bool createFrom(NativeRenderBuffer src) override
Similar to create() except that no new native renderbuffer objects are created.
QRhiTexture::Format backingFormat() const override
GLuint stencilRenderbuffer
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QVector< quint32 > serializedFormat() const override
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() const override
bool isCompatible(const QRhiRenderPassDescriptor *other) const override
~QGles2RenderPassDescriptor()
QGles2RenderPassDescriptor(QRhiImplementation *rhi)
std::optional< QRhiSwapChain::StereoTargetBuffer > stereoTarget
QGles2RenderPassDescriptor * rp
QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v, AddressMode w)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
void updateResources(UpdateFlags flags) override
~QGles2ShaderResourceBindings()
QGles2ShaderResourceBindings(QRhiImplementation *rhi)
float devicePixelRatio() const override
QGles2SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain)
QSize pixelSize() const override
int sampleCount() const override
~QGles2SwapChainRenderTarget()
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
void initSwapChainRenderTarget(QGles2SwapChainRenderTarget *rt)
QGles2SwapChainRenderTarget rtRight
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QGles2SwapChainRenderTarget rt
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
bool isFormatSupported(Format f) override
bool createOrResize() override
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size...
QGles2SwapChain(QRhiImplementation *rhi)
QRhiCommandBuffer * currentFrameCommandBuffer() override
QGles2SwapChainRenderTarget rtLeft
QSize surfacePixelSize() override
QRhiRenderTarget * currentFrameRenderTarget() override
int sampleCount() const override
QGles2TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags)
~QGles2TextureRenderTarget()
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
float devicePixelRatio() const override
QSize pixelSize() const override
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
bool create() override
Creates the corresponding native graphics resources.
bool createFrom(NativeTexture src) override
Similar to create(), except that no new native textures are created.
QGles2Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, Flags flags)
QGles2SamplerData samplerState
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
bool prepareCreate(QSize *adjustedSize=nullptr)
bool create() override
Creates the corresponding native graphics resources.
NativeTexture nativeTexture() override
QList< ShaderDesc > shaders
QByteArray cacheKey() const
uint needsDepthStencilCombinedAttach
uint srgbCapableDefaultFramebuffer
int maxThreadGroupsPerDimension
uint fixedIndexPrimitiveRestart
uint screenSpaceDerivatives
uint nonBaseLevelFramebufferTexture
int maxThreadsPerThreadGroup
QGles2CommandBuffer cbWrapper
\variable QRhiReadbackResult::completed
std::function< void()> completed
QRhiReadbackResult * result
QRhiTextureCopyDescription desc
QRhiReadbackDescription rb
QVarLengthArray< MipLevelUploadList, 6 > subresDesc
QRhiReadbackResult * result
\variable QShaderDescription::InOutVariable::name
struct QGles2CommandBuffer::Command::Args::@261 stencilRef
struct QGles2CommandBuffer::Command::Args::@290 compressedSubImage
struct QGles2CommandBuffer::Command::Args::@288 compressedImage
struct QGles2CommandBuffer::Command::Args::@305 barriersForPass
struct QGles2CommandBuffer::Command::Args::@268 bindShaderResources
struct QGles2CommandBuffer::Command::Args::@296 blitFromTexture
struct QGles2CommandBuffer::Command::Args::@300 bindComputePipeline
struct QGles2CommandBuffer::Command::Args::@260 blendConstants
struct QGles2CommandBuffer::Command::Args::@302 dispatch
struct QGles2CommandBuffer::Command::Args::@270 clear
struct QGles2CommandBuffer::Command::Args::@281 readPixels
struct QGles2CommandBuffer::Command::Args::@259 scissor
struct QGles2CommandBuffer::Command::Args::@298 genMip
struct QGles2CommandBuffer::Command::Args::@263 bindIndexBuffer
struct QGles2CommandBuffer::Command::Args::@285 subImage
uint dynamicOffsetPairs[MAX_DYNAMIC_OFFSET_COUNT *2]
QRhiShaderResourceBindings * srb
struct QGles2CommandBuffer::Command::Args::@273 bindFramebuffer
struct QGles2CommandBuffer::Command::Args::@276 getBufferSubData
QRhiGraphicsPipeline * maybeGraphicsPs
struct QGles2CommandBuffer::Command::Args::@264 draw
struct QGles2CommandBuffer::Command::Args::@275 bufferSubData
QRhiReadbackResult * result
struct QGles2CommandBuffer::Command::Args::@279 copyTex
struct QGles2CommandBuffer::Command::Args::@306 barrier
struct QGles2CommandBuffer::Command::Args::@258 viewport
struct QGles2CommandBuffer::Command::Args::@265 drawIndexed
QRhiComputePipeline * maybeComputePs
QRhiTexture::Format format
QRhiSwapChain::StereoTargetBuffer stereoTarget
QRhiGraphicsPipeline * ps
struct QGles2CommandBuffer::Command::Args::@266 bindGraphicsPipeline
struct QGles2CommandBuffer::Command::Args::@292 blitFromRenderbuffer
struct QGles2CommandBuffer::Command::Args::@262 bindVertexBuffer