Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qopenglprogrambinarycache_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOPENGLPROGRAMBINARYCACHE_P_H
5#define QOPENGLPROGRAMBINARYCACHE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/qtguiglobal.h>
19#include <QtCore/qcache.h>
20#include <QtCore/qmutex.h>
21#include <QtCore/QLoggingCategory>
22#include <QtGui/private/qopenglcontext_p.h>
23#include <rhi/qshader.h>
24
26
27// These classes are also used by the OpenGL backend of QRhi. They must
28// therefore stay independent from QOpenGLShader(Program). Must rely only on
29// QOpenGLContext/Functions.
30
31Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcOpenGLProgramDiskCache, Q_GUI_EXPORT)
32
33class Q_GUI_EXPORT QOpenGLProgramBinaryCache
34{
35public:
36 struct Q_GUI_EXPORT ShaderDesc {
39 : stage(stage), source(source)
40 { }
43 };
44 struct Q_GUI_EXPORT ProgramDesc {
45 QList<ShaderDesc> shaders;
46 QByteArray cacheKey() const;
47 };
48
50
51 bool load(const QByteArray &cacheKey, uint programId);
52 void save(const QByteArray &cacheKey, uint programId);
53
54private:
55 QString cacheFileName(const QByteArray &cacheKey) const;
56 bool verifyHeader(const QByteArray &buf) const;
57 bool setProgramBinary(uint programId, uint blobFormat, const void *p, uint blobSize);
58
59 QString m_globalCacheDir;
60 QString m_localCacheDir;
61 QString m_currentCacheDir;
62 bool m_cacheWritable;
63 struct MemCacheEntry {
64 MemCacheEntry(const void *p, int size, uint format)
65 : blob(reinterpret_cast<const char *>(p), size),
67 { }
68 QByteArray blob;
70 };
71 QCache<QByteArray, MemCacheEntry> m_memCache;
72#if QT_CONFIG(opengles2)
73 void (QOPENGLF_APIENTRYP programBinaryOES)(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
75 void initializeProgramBinaryOES(QOpenGLContext *context);
76 bool m_programBinaryOESInitialized = false;
77#endif
78 QMutex m_mutex;
79};
80
81// While unlikely, one application can in theory use contexts with different versions
82// or profiles. Therefore any version- or extension-specific checks must be done on a
83// per-context basis, not just once per process. QOpenGLSharedResource enables this,
84// although it's once-per-sharing-context-group, not per-context. Still, this should
85// be good enough in practice.
87{
88public:
90 void invalidateResource() override { }
91 void freeResource(QOpenGLContext *) override { }
92
93 bool isSupported() const { return m_supported; }
94
95private:
96 bool m_supported;
97};
98
110
112
113#endif
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtGui
The QOpenGLMultiGroupSharedResource keeps track of a shared resource that might be needed from multip...
QOpenGLSharedResource * value(QOpenGLContext *context)
QOpenGLProgramBinarySupportCheck * get(QOpenGLContext *context)
void freeResource(QOpenGLContext *) override
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
Stage
Describes the stage of the graphics pipeline the shader is suitable for.
Definition qshader.h:83
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
p1 load("image.bmp")
Combined button and popup list for selecting options.
static void * context
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
static QByteArray cacheKey(Args &&...args)
#define Q_DECLARE_EXPORTED_LOGGING_CATEGORY(name, export_macro)
#define QOPENGLF_APIENTRYP
Definition qopengl.h:275
GLsizei GLsizei GLenum void * binary
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
typedef GLsizei(GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target)
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint program
GLsizei GLsizei GLenum * binaryFormat
GLsizei bufSize
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLfloat GLfloat p
[1]
#define GLuint
unsigned int uint
Definition qtypes.h:34
ShaderDesc(QShader::Stage stage, const QByteArray &source=QByteArray())