Commit 8599a2b5 authored by Laszlo Agocs's avatar Laszlo Agocs

QBakedShader -> QRhiShader, examples -> manual tests

parent 702404fe
TEMPLATE = subdirs
SUBDIRS += \
rhi
......@@ -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
QBakedShader instances. The compilers and tools to generate such shaders are not
QRhiShader instances. The compilers and tools to generate such shaders are not
part of the Rhi module, but the core classes for using such shaders,
QBakedShader and QShaderDescription, are.
QRhiShader and QRhiShaderDescription, are.
\section1 Table of Contents
......
......@@ -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 QBakedShaderKey::StandardShader. A
QBakedShader pack contains multiple source and binary versions of a shader.
The shader variant \a v defaults to QRhiShaderKey::StandardShader. A
QRhiShader 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 QBakedShader &shader, QBakedShaderKey::ShaderVariant v)
QRhiGraphicsShaderStage::QRhiGraphicsShaderStage(Type type, const QRhiShader &shader, QRhiShaderKey::ShaderVariant v)
: m_type(type),
m_shader(shader),
m_shaderVariant(v)
......
......@@ -45,7 +45,7 @@
#include <QVector>
#include <QThread>
#include <QImage>
#include <QtRhi/QBakedShader>
#include <QtRhi/QRhiShader>
#include <functional>
QT_BEGIN_NAMESPACE
......@@ -282,22 +282,22 @@ public:
};
QRhiGraphicsShaderStage();
QRhiGraphicsShaderStage(Type type, const QBakedShader &shader,
QBakedShaderKey::ShaderVariant v = QBakedShaderKey::StandardShader);
QRhiGraphicsShaderStage(Type type, const QRhiShader &shader,
QRhiShaderKey::ShaderVariant v = QRhiShaderKey::StandardShader);
Type type() const { return m_type; }
void setType(Type t) { m_type = t; }
QBakedShader shader() const { return m_shader; }
void setShader(const QBakedShader &s) { m_shader = s; }
QRhiShader shader() const { return m_shader; }
void setShader(const QRhiShader &s) { m_shader = s; }
QBakedShaderKey::ShaderVariant shaderVariant() const { return m_shaderVariant; }
void setShaderVariant(QBakedShaderKey::ShaderVariant v) { m_shaderVariant = v; }
QRhiShaderKey::ShaderVariant shaderVariant() const { return m_shaderVariant; }
void setShaderVariant(QRhiShaderKey::ShaderVariant v) { m_shaderVariant = v; }
private:
Type m_type;
QBakedShader m_shader;
QBakedShaderKey::ShaderVariant m_shaderVariant = QBakedShaderKey::StandardShader;
QRhiShader m_shader;
QRhiShaderKey::ShaderVariant m_shaderVariant = QRhiShaderKey::StandardShader;
Q_DECL_UNUSED_MEMBER quint64 m_reserved;
};
......
......@@ -36,7 +36,7 @@
#include "qrhid3d11_p.h"
#include <QWindow>
#include <QBakedShader>
#include <QRhiShader>
#include <qmath.h>
#include <d3dcompiler.h>
......@@ -2745,13 +2745,13 @@ static inline D3D11_BLEND_OP toD3DBlendOp(QRhiGraphicsPipeline::BlendOp op)
}
}
static QByteArray compileHlslShaderSource(const QBakedShader &shader, QBakedShaderKey::ShaderVariant shaderVariant, QString *error)
static QByteArray compileHlslShaderSource(const QRhiShader &shader, QRhiShaderKey::ShaderVariant shaderVariant, QString *error)
{
QBakedShaderCode dxbc = shader.shader({ QBakedShaderKey::DxbcShader, 50, shaderVariant });
QRhiShaderCode dxbc = shader.shader({ QRhiShaderKey::DxbcShader, 50, shaderVariant });
if (!dxbc.shader().isEmpty())
return dxbc.shader();
QBakedShaderCode hlslSource = shader.shader({ QBakedShaderKey::HlslShader, 50, shaderVariant });
QRhiShaderCode hlslSource = shader.shader({ QRhiShaderKey::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 QBakedShader::VertexStage:
case QRhiShader::VertexStage:
target = "vs_5_0";
break;
case QBakedShader::TessControlStage:
case QRhiShader::TessControlStage:
target = "hs_5_0";
break;
case QBakedShader::TessEvaluationStage:
case QRhiShader::TessEvaluationStage:
target = "ds_5_0";
break;
case QBakedShader::GeometryStage:
case QRhiShader::GeometryStage:
target = "gs_5_0";
break;
case QBakedShader::FragmentStage:
case QRhiShader::FragmentStage:
target = "ps_5_0";
break;
case QBakedShader::ComputeStage:
case QRhiShader::ComputeStage:
target = "cs_5_0";
break;
default:
......
......@@ -43,7 +43,7 @@
#include "qrhid3d11.h"
#include "qrhi_p.h"
#include <QShaderDescription>
#include <QRhiShaderDescription>
#include <QWindow>
#include <d3d11_1.h>
......
......@@ -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 (QRhiShaderDescription). 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 QRhiShaderDescription::Float:
f->glUniform1f(uniform.glslLocation, *reinterpret_cast<const float *>(uniform.data.constData()));
break;
case QShaderDescription::Vec2:
case QRhiShaderDescription::Vec2:
f->glUniform2fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(uniform.data.constData()));
break;
case QShaderDescription::Vec3:
case QRhiShaderDescription::Vec3:
f->glUniform3fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(uniform.data.constData()));
break;
case QShaderDescription::Vec4:
case QRhiShaderDescription::Vec4:
f->glUniform4fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(uniform.data.constData()));
break;
case QShaderDescription::Mat2:
case QRhiShaderDescription::Mat2:
f->glUniformMatrix2fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(uniform.data.constData()));
break;
case QShaderDescription::Mat3:
case QRhiShaderDescription::Mat3:
f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(uniform.data.constData()));
break;
case QShaderDescription::Mat4:
case QRhiShaderDescription::Mat4:
f->glUniformMatrix4fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(uniform.data.constData()));
break;
case QShaderDescription::Int:
case QRhiShaderDescription::Int:
f->glUniform1i(uniform.glslLocation, *reinterpret_cast<const qint32 *>(uniform.data.constData()));
break;
case QShaderDescription::Int2:
case QRhiShaderDescription::Int2:
f->glUniform2iv(uniform.glslLocation, 1, reinterpret_cast<const qint32 *>(uniform.data.constData()));
break;
case QShaderDescription::Int3:
case QRhiShaderDescription::Int3:
f->glUniform3iv(uniform.glslLocation, 1, reinterpret_cast<const qint32 *>(uniform.data.constData()));
break;
case QShaderDescription::Int4:
case QRhiShaderDescription::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);
QBakedShaderVersion ver;
QRhiShaderVersion ver;
if (rhiD->ctx->isOpenGLES())
ver = { 100, QBakedShaderVersion::GlslEs };
ver = { 100, QRhiShaderVersion::GlslEs };
else
ver = { 120 };
const QBakedShader bakedShader = shaderStage.shader();
const QByteArray source = bakedShader.shader({ QBakedShaderKey::GlslShader, ver, shaderStage.shaderVariant() }).shader();
const QRhiShader bakedShader = shaderStage.shader();
const QByteArray source = bakedShader.shader({ QRhiShaderKey::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 QRhiShaderDescription::UniformBlock &ub) {
const QByteArray prefix = ub.structName.toUtf8() + '.';
for (const QShaderDescription::BlockVariable &blockMember : ub.members) {
for (const QRhiShaderDescription::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 QRhiShaderDescription::UniformBlock &ub : vsDesc.uniformBlocks())
lookupUniforms(ub);
for (const QShaderDescription::UniformBlock &ub : fsDesc.uniformBlocks())
for (const QRhiShaderDescription::UniformBlock &ub : fsDesc.uniformBlocks())
lookupUniforms(ub);
auto lookupSamplers = [this, rhiD](const QShaderDescription::InOutVariable &v) {
auto lookupSamplers = [this, rhiD](const QRhiShaderDescription::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 QRhiShaderDescription::InOutVariable &v : vsDesc.combinedImageSamplers())
lookupSamplers(v);
for (const QShaderDescription::InOutVariable &v : fsDesc.combinedImageSamplers())
for (const QRhiShaderDescription::InOutVariable &v : fsDesc.combinedImageSamplers())
lookupSamplers(v);
generation += 1;
......
......@@ -45,7 +45,7 @@
#include "qrhi_p.h"
#include <qopengl.h>
#include <QSurface>
#include <QShaderDescription>
#include <QRhiShaderDescription>
QT_BEGIN_NAMESPACE
......@@ -202,11 +202,11 @@ struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline
GLuint program = 0;
GLenum drawMode = GL_TRIANGLES;
QShaderDescription vsDesc;
QShaderDescription fsDesc;
QRhiShaderDescription vsDesc;
QRhiShaderDescription fsDesc;
struct Uniform {
QShaderDescription::VarType type;
QRhiShaderDescription::VarType type;
int glslLocation;
int binding;
uint offset;
......
......@@ -38,7 +38,7 @@
#include <QGuiApplication>
#include <QWindow>
#include <qmath.h>
#include <QBakedShader>
#include <QRhiShader>
#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 QBakedShader &shader, QBakedShaderKey::ShaderVariant shaderVariant,
id<MTLLibrary> createMetalLib(const QRhiShader &shader, QRhiShaderKey::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 QBakedShader &shader, QBakedShaderKey::ShaderVariant shaderVariant,
id<MTLLibrary> QRhiMetalData::createMetalLib(const QRhiShader &shader, QRhiShaderKey::ShaderVariant shaderVariant,
QString *error, QByteArray *entryPoint)
{
QBakedShaderCode mtllib = shader.shader({ QBakedShaderKey::MetalLibShader, 12, shaderVariant });
QRhiShaderCode mtllib = shader.shader({ QRhiShaderKey::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
}
}
QBakedShaderCode mslSource = shader.shader({ QBakedShaderKey::MslShader, 12, shaderVariant });
QRhiShaderCode mslSource = shader.shader({ QRhiShaderKey::MslShader, 12, shaderVariant });
if (mslSource.shader().isEmpty()) {
qWarning() << "No MSL 1.2 code found in baked shader" << shader;
return nil;
......
......@@ -43,7 +43,7 @@
#include "qrhimetal.h"
#include "qrhi_p.h"
#include <QShaderDescription>
#include <QRhiShaderDescription>
#include <QWindow>
QT_BEGIN_NAMESPACE
......
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt RHI module
......@@ -34,17 +34,17 @@
**
****************************************************************************/
#ifndef QBAKEDSHADER_H
#define QBAKEDSHADER_H
#ifndef QRHISHADER_H
#define QRHISHADER_H
#include <QtRhi/qtrhiglobal.h>
#include <QtRhi/qshaderdescription.h>
#include <QtRhi/qrhishaderdescription.h>
QT_BEGIN_NAMESPACE
struct QBakedShaderPrivate;
struct QRhiShaderPrivate;
class Q_RHI_EXPORT QBakedShaderVersion
class Q_RHI_EXPORT QRhiShaderVersion
{
public:
enum Flag {
......@@ -52,8 +52,8 @@ public:
};
Q_DECLARE_FLAGS(Flags, Flag)
QBakedShaderVersion() { }
QBakedShaderVersion(int v, Flags f = Flags())
QRhiShaderVersion() { }
QRhiShaderVersion(int v, Flags f = Flags())
: m_version(v), m_flags(f)
{ }
......@@ -68,10 +68,10 @@ private:
Flags m_flags;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QBakedShaderVersion::Flags)
Q_DECLARE_TYPEINFO(QBakedShaderVersion, Q_MOVABLE_TYPE);
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderVersion::Flags)
Q_DECLARE_TYPEINFO(QRhiShaderVersion, Q_MOVABLE_TYPE);
class Q_RHI_EXPORT QBakedShaderKey
class Q_RHI_EXPORT QRhiShaderKey
{
public:
enum ShaderSource {
......@@ -89,10 +89,10 @@ public:
BatchableVertexShader
};
QBakedShaderKey() { }
QBakedShaderKey(ShaderSource s,
const QBakedShaderVersion &sver,
ShaderVariant svar = StandardShader)
QRhiShaderKey() { }
QRhiShaderKey(ShaderSource s,
const QRhiShaderVersion &sver,
ShaderVariant svar = StandardShader)
: m_source(s),
m_sourceVersion(sver),
m_sourceVariant(svar)
......@@ -101,25 +101,25 @@ public:
ShaderSource source() const { return m_source; }
void setSource(ShaderSource s) { m_source = s; }
QBakedShaderVersion sourceVersion() const { return m_sourceVersion; }
void setSourceVersion(const QBakedShaderVersion &sver) { m_sourceVersion = sver; }
QRhiShaderVersion sourceVersion() const { return m_sourceVersion; }
void setSourceVersion(const QRhiShaderVersion &sver) { m_sourceVersion = sver; }
ShaderVariant sourceVariant() const { return m_sourceVariant; }
void setSourceVariant(ShaderVariant svar) { m_sourceVariant = svar; }
private:
ShaderSource m_source = SpirvShader;
QBakedShaderVersion m_sourceVersion;
QRhiShaderVersion m_sourceVersion;
ShaderVariant m_sourceVariant = StandardShader;
};
Q_DECLARE_TYPEINFO(QBakedShaderKey, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiShaderKey, Q_MOVABLE_TYPE);
class Q_RHI_EXPORT QBakedShaderCode
class Q_RHI_EXPORT QRhiShaderCode
{
public:
QBakedShaderCode() { }
QBakedShaderCode(const QByteArray &code, const QByteArray &entry = QByteArray())
QRhiShaderCode() { }
QRhiShaderCode(const QByteArray &code, const QByteArray &entry = QByteArray())
: m_shader(code), m_entryPoint(entry)
{ }
......@@ -134,9 +134,9 @@ private:
QByteArray m_entryPoint;
};
Q_DECLARE_TYPEINFO(QBakedShaderCode, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiShaderCode, Q_MOVABLE_TYPE);
class Q_RHI_EXPORT QBakedShader
class Q_RHI_EXPORT QRhiShader
{
public:
enum ShaderStage {
......@@ -148,10 +148,10 @@ public:
ComputeStage
};
QBakedShader();
QBakedShader(const QBakedShader &other);
QBakedShader &operator=(const QBakedShader &other);
~QBakedShader();
QRhiShader();
QRhiShader(const QRhiShader &other);
QRhiShader &operator=(const QRhiShader &other);
~QRhiShader();
void detach();
bool isValid() const;
......@@ -159,60 +159,60 @@ public:
ShaderStage stage() const;
void setStage(ShaderStage stage);
QShaderDescription description() const;
void setDescription(const QShaderDescription &desc);
QRhiShaderDescription description() const;
void setDescription(const QRhiShaderDescription &desc);
QList<QBakedShaderKey> availableShaders() const;
QBakedShaderCode shader(const QBakedShaderKey &key) const;
void setShader(const QBakedShaderKey &key, const QBakedShaderCode &shader);
void removeShader(const QBakedShaderKey &key);
QList<QRhiShaderKey> availableShaders() const;
QRhiShaderCode shader(const QRhiShaderKey &key) const;
void setShader(const QRhiShaderKey &key, const QRhiShaderCode &shader);
void removeShader(const QRhiShaderKey &key);
QByteArray serialized() const;
static QBakedShader fromSerialized(const QByteArray &data);
static QRhiShader fromSerialized(const QByteArray &data);
private:
QBakedShaderPrivate *d;
friend struct QBakedShaderPrivate;
friend Q_RHI_EXPORT bool operator==(const QBakedShader &, const QBakedShader &) Q_DECL_NOTHROW;
friend Q_RHI_EXPORT uint qHash(const QBakedShader &, uint) Q_DECL_NOTHROW;
QRhiShaderPrivate *d;
friend struct QRhiShaderPrivate;
friend Q_RHI_EXPORT bool operator==(const QRhiShader &, const QRhiShader &) Q_DECL_NOTHROW;
friend Q_RHI_EXPORT uint qHash(const QRhiShader &, uint) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM
friend Q_RHI_EXPORT QDebug operator<<(QDebug, const QBakedShader &);
friend Q_RHI_EXPORT QDebug operator<<(QDebug, const QRhiShader &);
#endif
};
Q_RHI_EXPORT bool operator==(const QBakedShader &lhs, const QBakedShader &rhs) Q_DECL_NOTHROW;
Q_RHI_EXPORT uint qHash(const QBakedShader &s, uint seed = 0) Q_DECL_NOTHROW;
Q_RHI_EXPORT bool operator==(const QRhiShader &lhs, const QRhiShader &rhs) Q_DECL_NOTHROW;
Q_RHI_EXPORT uint qHash(const QRhiShader &s, uint seed = 0) Q_DECL_NOTHROW;
inline bool operator!=(const QBakedShader &lhs, const QBakedShader &rhs) Q_DECL_NOTHROW
inline bool operator!=(const QRhiShader &lhs, const QRhiShader &rhs) Q_DECL_NOTHROW
{
return !(lhs == rhs);
}
Q_RHI_EXPORT bool operator==(const QBakedShaderVersion &lhs, const QBakedShaderVersion &rhs) Q_DECL_NOTHROW;
Q_RHI_EXPORT bool operator==(const QBakedShaderKey &lhs, const QBakedShaderKey &rhs) Q_DECL_NOTHROW;
Q_RHI_EXPORT bool operator==(const QBakedShaderCode &lhs, const QBakedShaderCode &rhs) Q_DECL_NOTHROW;
Q_RHI_EXPORT bool operator==(const QRhiShaderVersion &lhs, const QRhiShaderVersion &rhs) Q_DECL_NOTHROW;
Q_RHI_EXPORT bool operator==(const QRhiShaderKey &lhs, const QRhiShaderKey &rhs) Q_DECL_NOTHROW;
Q_RHI_EXPORT bool operator==(const QRhiShaderCode &lhs, const QRhiShaderCode &rhs) Q_DECL_NOTHROW;
inline bool operator!=(const QBakedShaderVersion &lhs, const QBakedShaderVersion &rhs) Q_DECL_NOTHROW
inline bool operator!=(const QRhiShaderVersion &lhs, const QRhiShaderVersion &rhs) Q_DECL_NOTHROW
{
return !(lhs == rhs);
}
inline bool operator!=(const QBakedShaderKey &lhs, const QBakedShaderKey &rhs) Q_DECL_NOTHROW
inline bool operator!=(const QRhiShaderKey &lhs, const QRhiShaderKey &rhs) Q_DECL_NOTHROW
{
return !(lhs == rhs);
}
inline bool operator!=(const QBakedShaderCode &lhs, const QBakedShaderCode &rhs) Q_DECL_NOTHROW
inline bool operator!=(const QRhiShaderCode &lhs, const QRhiShaderCode &rhs) Q_DECL_NOTHROW
{
return !(lhs == rhs);
}
Q_RHI_EXPORT uint qHash(const QBakedShaderKey &k, uint seed = 0) Q_DECL_NOTHROW;
Q_RHI_EXPORT uint qHash(const QRhiShaderKey &k, uint seed = 0) Q_DECL_NOTHROW;
#ifndef QT_NO_DEBUG_STREAM
Q_RHI_EXPORT QDebug operator<<(QDebug, const QBakedShader &);
Q_RHI_EXPORT QDebug operator<<(QDebug dbg, const QBakedShaderKey &k);
Q_RHI_EXPORT QDebug operator<<(QDebug dbg, const QBakedShaderVersion &v);
Q_RHI_EXPORT QDebug operator<<(QDebug, const QRhiShader &);
Q_RHI_EXPORT QDebug operator<<(QDebug dbg, const QRhiShaderKey &k);
Q_RHI_EXPORT QDebug operator<<(QDebug dbg, const QRhiShaderVersion &v);
#endif
QT_END_NAMESPACE
......
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt RHI module
......@@ -34,8 +34,8 @@
**
****************************************************************************/
#ifndef QBAKEDSHADER_P_H
#define QBAKEDSHADER_P_H
#ifndef QRHISHADER_P_H
#define QRHISHADER_P_H
//
// W A R N I N G
......@@ -49,21 +49,21 @@
//
#include "qtrhiglobal_p.h"
#include "qbakedshader.h"
#include "qrhishader.h"
#include <QtCore/QAtomicInt>
#include <QtCore/QHash>
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
struct Q_RHI_PRIVATE_EXPORT QBakedShaderPrivate
struct Q_RHI_PRIVATE_EXPORT QRhiShaderPrivate
{
QBakedShaderPrivate()
QRhiShaderPrivate()
: ref(1)
{
}
QBakedShaderPrivate(const QBakedShaderPrivate *other)
QRhiShaderPrivate(const QRhiShaderPrivate *other)
: ref(1),
stage(other->stage),
desc(other->desc),
......@@ -71,13 +71,13 @@ struct Q_RHI_PRIVATE_EXPORT QBakedShaderPrivate
{
}
static QBakedShaderPrivate *get(QBakedShader *s) { return s->d; }
static const QBakedShaderPrivate *get(const QBakedShader *s) { return s->d; }
static QRhiShaderPrivate *get(QRhiShader *s) { return s->d; }
static const QRhiShaderPrivate *get(const QRhiShader *s) { return s->d; }
QAtomicInt ref;
QBakedShader::ShaderStage stage = QBakedShader::VertexStage;
QShaderDescription desc;
QHash<QBakedShaderKey, QBakedShaderCode> shaders;
QRhiShader::ShaderStage stage = QRhiShader::VertexStage;
QRhiShaderDescription desc;
QHash<QRhiShaderKey, QRhiShaderCode> shaders;
};
QT_END_NAMESPACE
......
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt RHI module
......@@ -34,8 +34,8 @@
**
****************************************************************************/
#ifndef QSHADERDESCRIPTION_H
#define QSHADERDESCRIPTION_H
#ifndef QRHISHADERDESCRIPTION_H
#define QRHISHADERDESCRIPTION_H
#include <QtRhi/qtrhiglobal.h>
#include <QtCore/QString>
......@@ -43,15 +43,15 @@
QT_BEGIN_NAMESPACE
struct QShaderDescriptionPrivate;
struct QRhiShaderDescriptionPrivate;
class Q_RHI_EXPORT QShaderDescription
class Q_RHI_EXPORT QRhiShaderDescription
{
public:
QShaderDescription();
QShaderDescription(const QShaderDescription &other);
QShaderDescription &operator=(const QShaderDescription &other);
~QShaderDescription();
QRhiShaderDescription();
QRhiShaderDescription(const QRhiShaderDescription &other);
QRhiShaderDescription &operator=(const QRhiShaderDescription &other);
~QRhiShaderDescription();
void detach();
bool isValid() const;
......@@ -59,7 +59,7 @@ public:
QByteArray toBinaryJson() const;
QByteArray toJson() const;
static QShaderDescription fromBinaryJson(const QByteArray &data);
static QRhiShaderDescription fromBinaryJson(const QByteArray &data);
enum VarType {
Unknown = 0,
......@@ -166,19 +166,19 @@ public:
QVector<InOutVariable> combinedImageSamplers() const;
private:
QShaderDescriptionPrivate *d;
friend struct QShaderDescriptionPrivate;