Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laszlo Agocs
qtrhi
Commits
8599a2b5
Commit
8599a2b5
authored
Mar 21, 2019
by
Laszlo Agocs
Browse files
QBakedShader -> QRhiShader, examples -> manual tests
parent
702404fe
Changes
149
Expand all
Hide whitespace changes
Inline
Side-by-side
examples/examples.pro
deleted
100644 → 0
View file @
702404fe
TEMPLATE
=
subdirs
SUBDIRS
+=
\
rhi
src/rhi/doc/src/qtrhi-index.qdoc
View file @
8599a2b5
...
...
@@ -90,9 +90,9 @@ libraries, all shaders are expected to be written in a single language which is
then compiled into SPIR-V. Versions for various shading language are then
generated from that, together with reflection information (inputs, outputs,
shader resources). This is then packed into easily and efficiently serializable
Q
Baked
Shader instances. The compilers and tools to generate such shaders are not
Q
Rhi
Shader instances. The compilers and tools to generate such shaders are not
part of the Rhi module, but the core classes for using such shaders,
Q
Baked
Shader and QShaderDescription, are.
Q
Rhi
Shader and Q
Rhi
ShaderDescription, are.
\section1 Table of Contents
...
...
src/rhi/qrhi.cpp
View file @
8599a2b5
...
...
@@ -1160,12 +1160,12 @@ QRhiGraphicsShaderStage::QRhiGraphicsShaderStage()
Constructs a shader stage description with the \a type of the stage and the
\a shader.
The shader variant \a v defaults to Q
Baked
ShaderKey::StandardShader. A
Q
Baked
Shader pack contains multiple source and binary versions of a shader.
The shader variant \a v defaults to Q
Rhi
ShaderKey::StandardShader. A
Q
Rhi
Shader pack contains multiple source and binary versions of a shader.
In addition, it can also contain variants of the shader with slightly
modified code. \a v can then be used to select the desired variant.
*/
QRhiGraphicsShaderStage
::
QRhiGraphicsShaderStage
(
Type
type
,
const
Q
Baked
Shader
&
shader
,
Q
Baked
ShaderKey
::
ShaderVariant
v
)
QRhiGraphicsShaderStage
::
QRhiGraphicsShaderStage
(
Type
type
,
const
Q
Rhi
Shader
&
shader
,
Q
Rhi
ShaderKey
::
ShaderVariant
v
)
:
m_type
(
type
),
m_shader
(
shader
),
m_shaderVariant
(
v
)
...
...
src/rhi/qrhi.h
View file @
8599a2b5
...
...
@@ -45,7 +45,7 @@
#include <QVector>
#include <QThread>
#include <QImage>
#include <QtRhi/Q
Baked
Shader>
#include <QtRhi/Q
Rhi
Shader>
#include <functional>
QT_BEGIN_NAMESPACE
...
...
@@ -282,22 +282,22 @@ public:
};
QRhiGraphicsShaderStage
();
QRhiGraphicsShaderStage
(
Type
type
,
const
Q
Baked
Shader
&
shader
,
Q
Baked
ShaderKey
::
ShaderVariant
v
=
Q
Baked
ShaderKey
::
StandardShader
);
QRhiGraphicsShaderStage
(
Type
type
,
const
Q
Rhi
Shader
&
shader
,
Q
Rhi
ShaderKey
::
ShaderVariant
v
=
Q
Rhi
ShaderKey
::
StandardShader
);
Type
type
()
const
{
return
m_type
;
}
void
setType
(
Type
t
)
{
m_type
=
t
;
}
Q
Baked
Shader
shader
()
const
{
return
m_shader
;
}
void
setShader
(
const
Q
Baked
Shader
&
s
)
{
m_shader
=
s
;
}
Q
Rhi
Shader
shader
()
const
{
return
m_shader
;
}
void
setShader
(
const
Q
Rhi
Shader
&
s
)
{
m_shader
=
s
;
}
Q
Baked
ShaderKey
::
ShaderVariant
shaderVariant
()
const
{
return
m_shaderVariant
;
}
void
setShaderVariant
(
Q
Baked
ShaderKey
::
ShaderVariant
v
)
{
m_shaderVariant
=
v
;
}
Q
Rhi
ShaderKey
::
ShaderVariant
shaderVariant
()
const
{
return
m_shaderVariant
;
}
void
setShaderVariant
(
Q
Rhi
ShaderKey
::
ShaderVariant
v
)
{
m_shaderVariant
=
v
;
}
private:
Type
m_type
;
Q
Baked
Shader
m_shader
;
Q
Baked
ShaderKey
::
ShaderVariant
m_shaderVariant
=
Q
Baked
ShaderKey
::
StandardShader
;
Q
Rhi
Shader
m_shader
;
Q
Rhi
ShaderKey
::
ShaderVariant
m_shaderVariant
=
Q
Rhi
ShaderKey
::
StandardShader
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
...
...
src/rhi/qrhid3d11.cpp
View file @
8599a2b5
...
...
@@ -36,7 +36,7 @@
#include "qrhid3d11_p.h"
#include <QWindow>
#include <Q
Baked
Shader>
#include <Q
Rhi
Shader>
#include <qmath.h>
#include <d3dcompiler.h>
...
...
@@ -2745,13 +2745,13 @@ static inline D3D11_BLEND_OP toD3DBlendOp(QRhiGraphicsPipeline::BlendOp op)
}
}
static
QByteArray
compileHlslShaderSource
(
const
Q
Baked
Shader
&
shader
,
Q
Baked
ShaderKey
::
ShaderVariant
shaderVariant
,
QString
*
error
)
static
QByteArray
compileHlslShaderSource
(
const
Q
Rhi
Shader
&
shader
,
Q
Rhi
ShaderKey
::
ShaderVariant
shaderVariant
,
QString
*
error
)
{
Q
Baked
ShaderCode
dxbc
=
shader
.
shader
({
Q
Baked
ShaderKey
::
DxbcShader
,
50
,
shaderVariant
});
Q
Rhi
ShaderCode
dxbc
=
shader
.
shader
({
Q
Rhi
ShaderKey
::
DxbcShader
,
50
,
shaderVariant
});
if
(
!
dxbc
.
shader
().
isEmpty
())
return
dxbc
.
shader
();
Q
Baked
ShaderCode
hlslSource
=
shader
.
shader
({
Q
Baked
ShaderKey
::
HlslShader
,
50
,
shaderVariant
});
Q
Rhi
ShaderCode
hlslSource
=
shader
.
shader
({
Q
Rhi
ShaderKey
::
HlslShader
,
50
,
shaderVariant
});
if
(
hlslSource
.
shader
().
isEmpty
())
{
qWarning
()
<<
"No HLSL (shader model 5.0) code found in baked shader"
<<
shader
;
return
QByteArray
();
...
...
@@ -2759,22 +2759,22 @@ static QByteArray compileHlslShaderSource(const QBakedShader &shader, QBakedShad
const
char
*
target
;
switch
(
shader
.
stage
())
{
case
Q
Baked
Shader
::
VertexStage
:
case
Q
Rhi
Shader
::
VertexStage
:
target
=
"vs_5_0"
;
break
;
case
Q
Baked
Shader
::
TessControlStage
:
case
Q
Rhi
Shader
::
TessControlStage
:
target
=
"hs_5_0"
;
break
;
case
Q
Baked
Shader
::
TessEvaluationStage
:
case
Q
Rhi
Shader
::
TessEvaluationStage
:
target
=
"ds_5_0"
;
break
;
case
Q
Baked
Shader
::
GeometryStage
:
case
Q
Rhi
Shader
::
GeometryStage
:
target
=
"gs_5_0"
;
break
;
case
Q
Baked
Shader
::
FragmentStage
:
case
Q
Rhi
Shader
::
FragmentStage
:
target
=
"ps_5_0"
;
break
;
case
Q
Baked
Shader
::
ComputeStage
:
case
Q
Rhi
Shader
::
ComputeStage
:
target
=
"cs_5_0"
;
break
;
default:
...
...
src/rhi/qrhid3d11_p.h
View file @
8599a2b5
...
...
@@ -43,7 +43,7 @@
#include "qrhid3d11.h"
#include "qrhi_p.h"
#include <QShaderDescription>
#include <Q
Rhi
ShaderDescription>
#include <QWindow>
#include <d3d11_1.h>
...
...
src/rhi/qrhigles2.cpp
View file @
8599a2b5
...
...
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
OpenGL ES 2.0 (3.0) + GLSL 100/120 backend. Binding vertex attribute
locations and decomposing uniform buffers into uniforms (as expected by the
GLSL 1xx shader generated by SPIRV-Cross) are handled transparently to the
application via the reflection data (QShaderDescription). Textures and
application via the reflection data (Q
Rhi
ShaderDescription). Textures and
buffers feature no special logic, it's all just glTexSubImage2D and
glBufferSubData (with "dynamic" buffers set to GL_DYNAMIC_DRAW). The
swapchain and the associated renderbuffer for depth-stencil will be dummies
...
...
@@ -1737,37 +1737,37 @@ void QRhiGles2::setChangedUniforms(QRhiGraphicsPipeline *ps, QRhiShaderResourceB
memcpy
(
uniform
.
data
.
data
(),
bufView
.
constData
()
+
uniform
.
offset
,
uniform
.
data
.
size
());
switch
(
uniform
.
type
)
{
case
QShaderDescription
::
Float
:
case
Q
Rhi
ShaderDescription
::
Float
:
f
->
glUniform1f
(
uniform
.
glslLocation
,
*
reinterpret_cast
<
const
float
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Vec2
:
case
Q
Rhi
ShaderDescription
::
Vec2
:
f
->
glUniform2fv
(
uniform
.
glslLocation
,
1
,
reinterpret_cast
<
const
float
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Vec3
:
case
Q
Rhi
ShaderDescription
::
Vec3
:
f
->
glUniform3fv
(
uniform
.
glslLocation
,
1
,
reinterpret_cast
<
const
float
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Vec4
:
case
Q
Rhi
ShaderDescription
::
Vec4
:
f
->
glUniform4fv
(
uniform
.
glslLocation
,
1
,
reinterpret_cast
<
const
float
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Mat2
:
case
Q
Rhi
ShaderDescription
::
Mat2
:
f
->
glUniformMatrix2fv
(
uniform
.
glslLocation
,
1
,
GL_FALSE
,
reinterpret_cast
<
const
float
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Mat3
:
case
Q
Rhi
ShaderDescription
::
Mat3
:
f
->
glUniformMatrix3fv
(
uniform
.
glslLocation
,
1
,
GL_FALSE
,
reinterpret_cast
<
const
float
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Mat4
:
case
Q
Rhi
ShaderDescription
::
Mat4
:
f
->
glUniformMatrix4fv
(
uniform
.
glslLocation
,
1
,
GL_FALSE
,
reinterpret_cast
<
const
float
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Int
:
case
Q
Rhi
ShaderDescription
::
Int
:
f
->
glUniform1i
(
uniform
.
glslLocation
,
*
reinterpret_cast
<
const
qint32
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Int2
:
case
Q
Rhi
ShaderDescription
::
Int2
:
f
->
glUniform2iv
(
uniform
.
glslLocation
,
1
,
reinterpret_cast
<
const
qint32
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Int3
:
case
Q
Rhi
ShaderDescription
::
Int3
:
f
->
glUniform3iv
(
uniform
.
glslLocation
,
1
,
reinterpret_cast
<
const
qint32
*>
(
uniform
.
data
.
constData
()));
break
;
case
QShaderDescription
::
Int4
:
case
Q
Rhi
ShaderDescription
::
Int4
:
f
->
glUniform4iv
(
uniform
.
glslLocation
,
1
,
reinterpret_cast
<
const
qint32
*>
(
uniform
.
data
.
constData
()));
break
;
// ### more types
...
...
@@ -2558,13 +2558,13 @@ bool QGles2GraphicsPipeline::build()
continue
;
GLuint
shader
=
rhiD
->
f
->
glCreateShader
(
isVertex
?
GL_VERTEX_SHADER
:
GL_FRAGMENT_SHADER
);
Q
Baked
ShaderVersion
ver
;
Q
Rhi
ShaderVersion
ver
;
if
(
rhiD
->
ctx
->
isOpenGLES
())
ver
=
{
100
,
Q
Baked
ShaderVersion
::
GlslEs
};
ver
=
{
100
,
Q
Rhi
ShaderVersion
::
GlslEs
};
else
ver
=
{
120
};
const
Q
Baked
Shader
bakedShader
=
shaderStage
.
shader
();
const
QByteArray
source
=
bakedShader
.
shader
({
Q
Baked
ShaderKey
::
GlslShader
,
ver
,
shaderStage
.
shaderVariant
()
}).
shader
();
const
Q
Rhi
Shader
bakedShader
=
shaderStage
.
shader
();
const
QByteArray
source
=
bakedShader
.
shader
({
Q
Rhi
ShaderKey
::
GlslShader
,
ver
,
shaderStage
.
shaderVariant
()
}).
shader
();
if
(
source
.
isEmpty
())
{
qWarning
()
<<
"No GLSL"
<<
ver
.
version
()
<<
"shader code found in baked shader"
<<
bakedShader
;
return
false
;
...
...
@@ -2618,9 +2618,9 @@ bool QGles2GraphicsPipeline::build()
return
false
;
}
auto
lookupUniforms
=
[
this
,
rhiD
](
const
QShaderDescription
::
UniformBlock
&
ub
)
{
auto
lookupUniforms
=
[
this
,
rhiD
](
const
Q
Rhi
ShaderDescription
::
UniformBlock
&
ub
)
{
const
QByteArray
prefix
=
ub
.
structName
.
toUtf8
()
+
'.'
;
for
(
const
QShaderDescription
::
BlockVariable
&
blockMember
:
ub
.
members
)
{
for
(
const
Q
Rhi
ShaderDescription
::
BlockVariable
&
blockMember
:
ub
.
members
)
{
// ### no array support for now
Uniform
uniform
;
uniform
.
type
=
blockMember
.
type
;
...
...
@@ -2635,13 +2635,13 @@ bool QGles2GraphicsPipeline::build()
}
};
for
(
const
QShaderDescription
::
UniformBlock
&
ub
:
vsDesc
.
uniformBlocks
())
for
(
const
Q
Rhi
ShaderDescription
::
UniformBlock
&
ub
:
vsDesc
.
uniformBlocks
())
lookupUniforms
(
ub
);
for
(
const
QShaderDescription
::
UniformBlock
&
ub
:
fsDesc
.
uniformBlocks
())
for
(
const
Q
Rhi
ShaderDescription
::
UniformBlock
&
ub
:
fsDesc
.
uniformBlocks
())
lookupUniforms
(
ub
);
auto
lookupSamplers
=
[
this
,
rhiD
](
const
QShaderDescription
::
InOutVariable
&
v
)
{
auto
lookupSamplers
=
[
this
,
rhiD
](
const
Q
Rhi
ShaderDescription
::
InOutVariable
&
v
)
{
Sampler
sampler
;
const
QByteArray
name
=
v
.
name
.
toUtf8
();
sampler
.
glslLocation
=
rhiD
->
f
->
glGetUniformLocation
(
program
,
name
.
constData
());
...
...
@@ -2651,10 +2651,10 @@ bool QGles2GraphicsPipeline::build()
}
};
for
(
const
QShaderDescription
::
InOutVariable
&
v
:
vsDesc
.
combinedImageSamplers
())
for
(
const
Q
Rhi
ShaderDescription
::
InOutVariable
&
v
:
vsDesc
.
combinedImageSamplers
())
lookupSamplers
(
v
);
for
(
const
QShaderDescription
::
InOutVariable
&
v
:
fsDesc
.
combinedImageSamplers
())
for
(
const
Q
Rhi
ShaderDescription
::
InOutVariable
&
v
:
fsDesc
.
combinedImageSamplers
())
lookupSamplers
(
v
);
generation
+=
1
;
...
...
src/rhi/qrhigles2_p.h
View file @
8599a2b5
...
...
@@ -45,7 +45,7 @@
#include "qrhi_p.h"
#include <qopengl.h>
#include <QSurface>
#include <QShaderDescription>
#include <Q
Rhi
ShaderDescription>
QT_BEGIN_NAMESPACE
...
...
@@ -202,11 +202,11 @@ struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline
GLuint
program
=
0
;
GLenum
drawMode
=
GL_TRIANGLES
;
QShaderDescription
vsDesc
;
QShaderDescription
fsDesc
;
Q
Rhi
ShaderDescription
vsDesc
;
Q
Rhi
ShaderDescription
fsDesc
;
struct
Uniform
{
QShaderDescription
::
VarType
type
;
Q
Rhi
ShaderDescription
::
VarType
type
;
int
glslLocation
;
int
binding
;
uint
offset
;
...
...
src/rhi/qrhimetal.mm
View file @
8599a2b5
...
...
@@ -38,7 +38,7 @@
#include <QGuiApplication>
#include <QWindow>
#include <qmath.h>
#include <Q
Baked
Shader>
#include <Q
Rhi
Shader>
#include <AppKit/AppKit.h>
#include <Metal/Metal.h>
#include <QuartzCore/CAMetalLayer.h>
...
...
@@ -129,7 +129,7 @@ struct QRhiMetalData
const
QRhiColorClearValue
&
colorClearValue
,
const
QRhiDepthStencilClearValue
&
depthStencilClearValue
,
int
colorAttCount
);
id
<
MTLLibrary
>
createMetalLib
(
const
Q
Baked
Shader
&
shader
,
Q
Baked
ShaderKey
::
ShaderVariant
shaderVariant
,
id
<
MTLLibrary
>
createMetalLib
(
const
Q
Rhi
Shader
&
shader
,
Q
Rhi
ShaderKey
::
ShaderVariant
shaderVariant
,
QString
*
error
,
QByteArray
*
entryPoint
);
id
<
MTLFunction
>
createMSLShaderFunction
(
id
<
MTLLibrary
>
lib
,
const
QByteArray
&
entryPoint
);
...
...
@@ -2722,10 +2722,10 @@ static inline MTLCullMode toMetalCullMode(QRhiGraphicsPipeline::CullMode c)
}
}
id
<
MTLLibrary
>
QRhiMetalData
::
createMetalLib
(
const
Q
Baked
Shader
&
shader
,
Q
Baked
ShaderKey
::
ShaderVariant
shaderVariant
,
id
<
MTLLibrary
>
QRhiMetalData
::
createMetalLib
(
const
Q
Rhi
Shader
&
shader
,
Q
Rhi
ShaderKey
::
ShaderVariant
shaderVariant
,
QString
*
error
,
QByteArray
*
entryPoint
)
{
Q
Baked
ShaderCode
mtllib
=
shader
.
shader
({
Q
Baked
ShaderKey
::
MetalLibShader
,
12
,
shaderVariant
});
Q
Rhi
ShaderCode
mtllib
=
shader
.
shader
({
Q
Rhi
ShaderKey
::
MetalLibShader
,
12
,
shaderVariant
});
if
(
!
mtllib
.
shader
().
isEmpty
())
{
dispatch_data_t
data
=
dispatch_data_create
(
mtllib
.
shader
().
constData
(),
mtllib
.
shader
().
size
(),
...
...
@@ -2743,7 +2743,7 @@ id<MTLLibrary> QRhiMetalData::createMetalLib(const QBakedShader &shader, QBakedS
}
}
Q
Baked
ShaderCode
mslSource
=
shader
.
shader
({
Q
Baked
ShaderKey
::
MslShader
,
12
,
shaderVariant
});
Q
Rhi
ShaderCode
mslSource
=
shader
.
shader
({
Q
Rhi
ShaderKey
::
MslShader
,
12
,
shaderVariant
});
if
(
mslSource
.
shader
().
isEmpty
())
{
qWarning
()
<<
"No MSL 1.2 code found in baked shader"
<<
shader
;
return
nil
;
...
...
src/rhi/qrhimetal_p.h
View file @
8599a2b5
...
...
@@ -43,7 +43,7 @@
#include "qrhimetal.h"
#include "qrhi_p.h"
#include <QShaderDescription>
#include <Q
Rhi
ShaderDescription>
#include <QWindow>
QT_BEGIN_NAMESPACE
...
...
src/rhi/q
baked
shader.cpp
→
src/rhi/q
rhi
shader.cpp
View file @
8599a2b5
/****************************************************************************
**
** Copyright (C) 201
7
The Qt Company Ltd.
** Copyright (C) 201
9
The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt RHI module
...
...
@@ -34,26 +34,26 @@
**
****************************************************************************/
#include "q
baked
shader_p.h"
#include "q
rhi
shader_p.h"
#include <QDataStream>
#include <QBuffer>
QT_BEGIN_NAMESPACE
/*!
\class Q
Baked
Shader
\class Q
Rhi
Shader
\inmodule QtRhi
\brief Contains multiple versions of a shader translated to multiple shading languages,
together with reflection metadata.
Q
Baked
Shader is the entry point to shader code in the graphics API agnostic
Q
Rhi
Shader is the entry point to shader code in the graphics API agnostic
Qt world. Instead of using GLSL shader sources, as was the custom with Qt
5.x, new graphics systems with backends for multiple graphics APIs, such
as, Vulkan, Metal, Direct3D, and OpenGL, take Q
Baked
Shader as their input
as, Vulkan, Metal, Direct3D, and OpenGL, take Q
Rhi
Shader as their input
whenever a shader needs to be specified.
A Q
Baked
Shader instance is empty and thus invalid by default. To get a useful
A Q
Rhi
Shader instance is empty and thus invalid by default. To get a useful
instance, the two typical methods are:
\list
...
...
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
When used together with the Qt Rendering Hardware Interface and its
classes, like QRhiGraphicsPipeline, no further action is needed from the
application's side as these classes are prepared to consume a Q
Baked
Shader
application's side as these classes are prepared to consume a Q
Rhi
Shader
whenever a shader needs to be specified for a given stage of the graphics
pipeline.
...
...
@@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE
\list
\li the source or byte code for any of the shading language versions that
are included in the Q
Baked
Shader,
are included in the Q
Rhi
Shader,
\li the name of the entry point for the shader,
...
...
@@ -92,15 +92,15 @@ QT_BEGIN_NAMESPACE
\endlist
Q
Baked
Shader makes no assumption about the shading language that was used
Q
Rhi
Shader makes no assumption about the shading language that was used
as the source for generating the various versions and variants that are
included in it.
Q
Baked
Shader uses implicit sharing similarly to many core Qt types, and so
Q
Rhi
Shader uses implicit sharing similarly to many core Qt types, and so
can be returned or passed by value. Detach happens implicitly when calling
a setter.
For reference, QRhi expects that a Q
Baked
Shader suitable for all its
For reference, QRhi expects that a Q
Rhi
Shader suitable for all its
backends contains at least the following:
\list
...
...
@@ -121,7 +121,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
\enum Q
Baked
Shader::ShaderStage
\enum Q
Rhi
Shader::ShaderStage
Describes the stage of the graphics pipeline the shader is suitable for.
\value VertexStage Vertex shader
...
...
@@ -133,7 +133,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
\class Q
Baked
ShaderVersion
\class Q
Rhi
ShaderVersion
\inmodule QtRhi
\brief Specifies the shading language version.
...
...
@@ -157,12 +157,12 @@ QT_BEGIN_NAMESPACE
\li Metal: 12, 20
\endlist
A default constructed Q
Baked
ShaderVersion contains a version of 100 and no
A default constructed Q
Rhi
ShaderVersion contains a version of 100 and no
flags set.
*/
/*!
\enum Q
Baked
ShaderVersion::Flag
\enum Q
Rhi
ShaderVersion::Flag
Describes the flags that can be set.
...
...
@@ -170,17 +170,17 @@ QT_BEGIN_NAMESPACE
*/
/*!
\class Q
Baked
ShaderKey
\class Q
Rhi
ShaderKey
\inmodule QtRhi
\brief Specifies the shading language, the version with flags, and the variant.
A default constructed Q
Baked
ShaderKey has source set to SpirvShader and
A default constructed Q
Rhi
ShaderKey has source set to SpirvShader and
sourceVersion set to 100. sourceVariant defaults to StandardShader.
*/
/*!
\enum Q
Baked
ShaderKey::ShaderSource
\enum Q
Rhi
ShaderKey::ShaderSource
Describes what kind of shader code an entry contains.
\value SpirvShader SPIR-V
...
...
@@ -193,7 +193,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
\enum Q
Baked
ShaderKey::ShaderVariant
\enum Q
Rhi
ShaderKey::ShaderVariant
Describes what kind of shader code an entry contains.
\value StandardShader The normal, unmodified version of the shader code.
...
...
@@ -201,29 +201,29 @@ QT_BEGIN_NAMESPACE
*/
/*!
\class Q
Baked
ShaderCode
\class Q
Rhi
ShaderCode
\inmodule QtRhi
\brief Contains source or binary code for a shader and additional metadata.
When shader() is empty after retrieving a Q
Baked
ShaderCode instance from
Q
Baked
Shader, it indicates no shader code was found for the requested key.
When shader() is empty after retrieving a Q
Rhi
ShaderCode instance from
Q
Rhi
Shader, it indicates no shader code was found for the requested key.
*/
static
const
int
QSB_VERSION
=
1
;
/*!
Constructs a new, empty (and thus invalid) Q
Baked
Shader instance.
Constructs a new, empty (and thus invalid) Q
Rhi
Shader instance.
*/
Q
Baked
Shader
::
Q
Baked
Shader
()
:
d
(
new
Q
Baked
ShaderPrivate
)
Q
Rhi
Shader
::
Q
Rhi
Shader
()
:
d
(
new
Q
Rhi
ShaderPrivate
)
{
}
/*!
\internal
*/
void
Q
Baked
Shader
::
detach
()
void
Q
Rhi
Shader
::
detach
()
{
qAtomicDetach
(
d
);
}
...
...
@@ -231,7 +231,7 @@ void QBakedShader::detach()
/*!
\internal
*/
Q
Baked
Shader
::
Q
Baked
Shader
(
const
Q
Baked
Shader
&
other
)
Q
Rhi
Shader
::
Q
Rhi
Shader
(
const
Q
Rhi
Shader
&
other
)
:
d
(
other
.
d
)
{
d
->
ref
.
ref
();
...
...
@@ -240,7 +240,7 @@ QBakedShader::QBakedShader(const QBakedShader &other)
/*!
\internal
*/
Q
Baked
Shader
&
Q
Baked
Shader
::
operator
=
(
const
Q
Baked
Shader
&
other
)
Q
Rhi
Shader
&
Q
Rhi
Shader
::
operator
=
(
const
Q
Rhi
Shader
&
other
)
{
qAtomicAssign
(
d
,
other
.
d
);
return
*
this
;
...
...
@@ -249,16 +249,16 @@ QBakedShader &QBakedShader::operator=(const QBakedShader &other)
/*!
Destructor.
*/
Q
Baked
Shader
::~
Q
Baked
Shader
()
Q
Rhi
Shader
::~
Q
Rhi
Shader
()
{
if
(
!
d
->
ref
.
deref
())
delete
d
;
}
/*!
\return true if the Q
Baked
Shader contains at least one shader version.
\return true if the Q
Rhi
Shader contains at least one shader version.
*/
bool
Q
Baked
Shader
::
isValid
()
const
bool
Q
Rhi
Shader
::
isValid
()
const
{
return
!
d
->
shaders
.
isEmpty
();
}
...
...
@@ -266,7 +266,7 @@ bool QBakedShader::isValid() const
/*!
\return the pipeline stage the shader is meant for.
*/
Q
Baked
Shader
::
ShaderStage
Q
Baked
Shader
::
stage
()
const
Q
Rhi
Shader
::
ShaderStage
Q
Rhi
Shader
::
stage
()
const
{
return
d
->
stage
;
}
...
...
@@ -274,7 +274,7 @@ QBakedShader::ShaderStage QBakedShader::stage() const
/*!
Sets the pipeline \a stage.
*/
void
Q
Baked
Shader
::
setStage
(
ShaderStage
stage
)
void
Q
Rhi
Shader
::
setStage
(
ShaderStage
stage
)
{
if
(
stage
!=
d
->
stage
)
{
detach
();
...
...
@@ -285,7 +285,7 @@ void QBakedShader::setStage(ShaderStage stage)
/*!
\return the reflection metadata for the shader.
*/
QShaderDescription
Q
Baked
Shader
::
description
()
const
Q
Rhi
ShaderDescription
Q
Rhi
Shader
::
description
()
const
{
return
d
->
desc
;
}
...
...
@@ -293,7 +293,7 @@ QShaderDescription QBakedShader::description() const
/*!
Sets the reflection metadata to \a desc.
*/
void
Q
Baked
Shader
::
setDescription
(
const
QShaderDescription
&
desc
)
void
Q
Rhi
Shader
::
setDescription
(
const
Q
Rhi
ShaderDescription
&
desc
)
{
detach
();
d
->
desc
=
desc
;
...
...
@@ -302,7 +302,7 @@ void QBakedShader::setDescription(const QShaderDescription &desc)
/*!
\return the list of available shader versions
*/
QList
<
Q
Baked
ShaderKey
>
Q
Baked
Shader
::
availableShaders
()
const
QList
<
Q
Rhi
ShaderKey
>
Q
Rhi
Shader
::
availableShaders
()
const
{
return
d
->
shaders
.
keys
();
}
...
...
@@ -310,7 +310,7 @@ QList<QBakedShaderKey> QBakedShader::availableShaders() const
/*!
\return the source or binary code for a given shader version specified by \a key.
*/
Q
Baked
ShaderCode
Q
Baked
Shader
::
shader
(
const
Q
Baked
ShaderKey
&
key
)
const
Q
Rhi
ShaderCode
Q
Rhi
Shader
::
shader
(
const
Q
Rhi
ShaderKey
&
key
)
const
{
return
d
->
shaders
.
value
(
key
);
}
...
...
@@ -318,7 +318,7 @@ QBakedShaderCode QBakedShader::shader(const QBakedShaderKey &key) const
/*!
Stores the source or binary \a shader code for a given shader version specified by \a key.
*/
void
Q
Baked
Shader
::
setShader
(
const
Q
Baked
ShaderKey
&
key
,
const
Q
Baked
ShaderCode
&
shader
)
void
Q
Rhi
Shader
::
setShader
(
const
Q
Rhi
ShaderKey
&
key
,
const
Q
Rhi
ShaderCode
&
shader
)
{
if
(
d
->
shaders
.
value
(
key
)
==
shader
)
return
;
...
...
@@ -331,7 +331,7 @@ void QBakedShader::setShader(const QBakedShaderKey &key, const QBakedShaderCode
Removes the source or binary shader code for a given \a key.
Does nothing when not found.
*/
void
Q
Baked
Shader
::
removeShader
(
const
Q
Baked
ShaderKey
&
key
)
void
Q
Rhi
Shader
::
removeShader
(
const
Q
Rhi
ShaderKey
&
key
)
{
auto
it
=
d
->
shaders
.
find
(
key
);
if
(
it
==
d
->
shaders
.
end
())
...
...
@@ -343,11 +343,11 @@ void QBakedShader::removeShader(const QBakedShaderKey &key)
/*!
\return a serialized binary version of all the data held by the
Q
Baked
Shader, suitable for writing to files or other I/O devices.
Q
Rhi
Shader, suitable for writing to files or other I/O devices.
\sa fromSerialized()
*/
QByteArray
Q
Baked
Shader
::
serialized
()
const
QByteArray
Q
Rhi
Shader
::
serialized
()
const
{
QBuffer
buf
;
QDataStream
ds
(
&
buf
);
...
...
@@ -360,12 +360,12 @@ QByteArray QBakedShader::serialized() const
ds
<<
d
->
desc
.
toBinaryJson
();
ds
<<
d
->
shaders
.
count
();
for
(
auto
it
=
d
->
shaders
.
cbegin
(),
itEnd
=
d
->
shaders
.
cend
();
it
!=
itEnd
;
++
it
)
{
const
Q
Baked
ShaderKey
&
k
(
it
.
key
());
const
Q
Rhi
ShaderKey
&
k
(
it
.
key
());
ds
<<
k
.
source
();
ds
<<
k
.
sourceVersion
().
version
();