Skip to content
GitLab
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
0709ec13
Commit
0709ec13
authored
Jan 19, 2019
by
Laszlo Agocs
Browse files
Migrate mtl to follow ShaderResourceBinding change
parent
6070d12a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/rhi/qrhi.h
View file @
0709ec13
...
...
@@ -166,7 +166,7 @@ private:
quint32
m_stride
;
Classification
m_classification
;
int
m_instanceStepRate
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiVertexInputBinding
,
Q_MOVABLE_TYPE
);
...
...
@@ -206,7 +206,7 @@ private:
int
m_location
;
Format
m_format
;
quint32
m_offset
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiVertexInputAttribute
,
Q_MOVABLE_TYPE
);
...
...
@@ -223,7 +223,7 @@ public:
private:
QVector
<
QRhiVertexInputBinding
>
m_bindings
;
QVector
<
QRhiVertexInputAttribute
>
m_attributes
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiVertexInputLayout
,
Q_MOVABLE_TYPE
);
...
...
@@ -252,7 +252,7 @@ public:
private:
Type
m_type
;
QBakedShader
m_shader
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiGraphicsShaderStage
,
Q_MOVABLE_TYPE
);
...
...
@@ -289,7 +289,6 @@ private:
};
Q_DECLARE_OPERATORS_FOR_FLAGS
(
QRhiShaderResourceBinding
::
StageFlags
)
Q_DECLARE_TYPEINFO
(
QRhiShaderResourceBinding
,
Q_MOVABLE_TYPE
);
class
Q_RHI_EXPORT
QRhiColorAttachment
{
...
...
@@ -327,7 +326,7 @@ private:
QRhiTexture
*
m_resolveTexture
=
nullptr
;
int
m_resolveLayer
=
0
;
int
m_resolveLevel
=
0
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiColorAttachment
,
Q_MOVABLE_TYPE
);
...
...
@@ -359,7 +358,7 @@ private:
QVector
<
QRhiColorAttachment
>
m_colorAttachments
;
QRhiRenderBuffer
*
m_depthStencilBuffer
=
nullptr
;
QRhiTexture
*
m_depthTexture
=
nullptr
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiTextureRenderTargetDescription
,
Q_MOVABLE_TYPE
);
...
...
@@ -392,7 +391,7 @@ private:
QPoint
m_destinationTopLeft
;
QSize
m_sourceSize
;
QPoint
m_sourceTopLeft
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiTextureMipLevel
,
Q_MOVABLE_TYPE
);
...
...
@@ -408,7 +407,7 @@ public:
private:
QVector
<
QRhiTextureMipLevel
>
m_mipImages
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiTextureLayer
,
Q_MOVABLE_TYPE
);
...
...
@@ -424,7 +423,7 @@ public:
private:
QVector
<
QRhiTextureLayer
>
m_layers
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiTextureUploadDescription
,
Q_MOVABLE_TYPE
);
...
...
@@ -463,7 +462,7 @@ private:
int
m_destinationLayer
=
0
;
int
m_destinationLevel
=
0
;
QPoint
m_destinationTopLeft
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiTextureCopyDescription
,
Q_MOVABLE_TYPE
);
...
...
@@ -487,7 +486,7 @@ private:
QRhiTexture
*
m_texture
=
nullptr
;
int
m_layer
=
0
;
int
m_level
=
0
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_TYPEINFO
(
QRhiReadbackDescription
,
Q_MOVABLE_TYPE
);
...
...
@@ -546,7 +545,7 @@ protected:
Type
m_type
;
UsageFlags
m_usage
;
int
m_size
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_OPERATORS_FOR_FLAGS
(
QRhiBuffer
::
UsageFlags
)
...
...
@@ -627,7 +626,7 @@ protected:
QSize
m_pixelSize
;
int
m_sampleCount
;
Flags
m_flags
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_OPERATORS_FOR_FLAGS
(
QRhiTexture
::
Flags
)
...
...
@@ -679,7 +678,7 @@ protected:
AddressMode
m_addressU
;
AddressMode
m_addressV
;
AddressMode
m_addressW
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
class
Q_RHI_EXPORT
QRhiRenderBuffer
:
public
QRhiResource
...
...
@@ -718,7 +717,7 @@ protected:
QSize
m_pixelSize
;
int
m_sampleCount
;
Flags
m_flags
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_OPERATORS_FOR_FLAGS
(
QRhiRenderBuffer
::
Flags
)
...
...
@@ -727,7 +726,7 @@ class Q_RHI_EXPORT QRhiRenderPassDescriptor : public QRhiResource
{
protected:
QRhiRenderPassDescriptor
(
QRhiImplementation
*
rhi
);
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
class
Q_RHI_EXPORT
QRhiRenderTarget
:
public
QRhiResource
...
...
@@ -748,7 +747,7 @@ public:
protected:
QRhiRenderTarget
(
QRhiImplementation
*
rhi
);
QRhiRenderPassDescriptor
*
m_renderPassDesc
=
nullptr
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
class
Q_RHI_EXPORT
QRhiTextureRenderTarget
:
public
QRhiRenderTarget
...
...
@@ -789,7 +788,7 @@ public:
protected:
QRhiShaderResourceBindings
(
QRhiImplementation
*
rhi
);
QVector
<
QRhiShaderResourceBinding
>
m_bindings
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
class
Q_RHI_EXPORT
QRhiGraphicsPipeline
:
public
QRhiResource
...
...
@@ -975,7 +974,7 @@ protected:
QRhiVertexInputLayout
m_vertexInputLayout
;
QRhiShaderResourceBindings
*
m_shaderResourceBindings
=
nullptr
;
QRhiRenderPassDescriptor
*
m_renderPassDesc
=
nullptr
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_OPERATORS_FOR_FLAGS
(
QRhiGraphicsPipeline
::
Flags
)
...
...
@@ -1029,7 +1028,7 @@ protected:
QRhiRenderPassDescriptor
*
m_renderPassDesc
=
nullptr
;
QObject
*
m_target
=
nullptr
;
QSize
m_currentPixelSize
;
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
Q_DECLARE_OPERATORS_FOR_FLAGS
(
QRhiSwapChain
::
Flags
)
...
...
@@ -1080,7 +1079,7 @@ public:
protected:
QRhiCommandBuffer
(
QRhiImplementation
*
rhi
);
Q_DECL_UNUSED_MEMBER
void
*
m_reserved
;
Q_DECL_UNUSED_MEMBER
quint64
m_reserved
;
};
struct
Q_RHI_EXPORT
QRhiReadbackResult
...
...
src/rhi/qrhimetal.mm
View file @
0709ec13
...
...
@@ -508,33 +508,34 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD
QRhiBatchedBindings
<
id
<
MTLSamplerState
>
>
samplers
;
}
res
[
KNOWN_STAGES
];
for
(
const
QRhiShaderResourceBinding
&
b
:
qAsConst
(
srbD
->
sortedBindings
))
{
switch
(
b
.
type
)
{
for
(
const
QRhiShaderResourceBinding
&
binding
:
qAsConst
(
srbD
->
sortedBindings
))
{
const
QRhiShaderResourceBindingPrivate
*
b
=
QRhiShaderResourceBindingPrivate
::
get
(
&
binding
);
switch
(
b
->
type
)
{
case
QRhiShaderResourceBinding
::
UniformBuffer
:
{
QMetalBuffer
*
bufD
=
QRHI_RES
(
QMetalBuffer
,
b
.
ubuf
.
buf
);
QMetalBuffer
*
bufD
=
QRHI_RES
(
QMetalBuffer
,
b
->
u
.
ubuf
.
buf
);
id
<
MTLBuffer
>
mtlbuf
=
bufD
->
d
->
buf
[
bufD
->
m_type
==
QRhiBuffer
:
:
Immutable
?
0
:
currentFrameSlot
];
if
(
b
.
stage
.
testFlag
(
QRhiShaderResourceBinding
::
VertexStage
))
{
res
[
0
].
buffers
.
feed
(
b
.
binding
,
mtlbuf
);
res
[
0
].
bufferOffsets
.
feed
(
b
.
binding
,
b
.
ubuf
.
offset
);
if
(
b
->
stage
.
testFlag
(
QRhiShaderResourceBinding
::
VertexStage
))
{
res
[
0
].
buffers
.
feed
(
b
->
binding
,
mtlbuf
);
res
[
0
].
bufferOffsets
.
feed
(
b
->
binding
,
b
->
u
.
ubuf
.
offset
);
}
if
(
b
.
stage
.
testFlag
(
QRhiShaderResourceBinding
::
FragmentStage
))
{
res
[
1
].
buffers
.
feed
(
b
.
binding
,
mtlbuf
);
res
[
1
].
bufferOffsets
.
feed
(
b
.
binding
,
b
.
ubuf
.
offset
);
if
(
b
->
stage
.
testFlag
(
QRhiShaderResourceBinding
::
FragmentStage
))
{
res
[
1
].
buffers
.
feed
(
b
->
binding
,
mtlbuf
);
res
[
1
].
bufferOffsets
.
feed
(
b
->
binding
,
b
->
u
.
ubuf
.
offset
);
}
}
break
;
case
QRhiShaderResourceBinding
::
SampledTexture
:
{
QMetalTexture
*
texD
=
QRHI_RES
(
QMetalTexture
,
b
.
stex
.
tex
);
QMetalSampler
*
samplerD
=
QRHI_RES
(
QMetalSampler
,
b
.
stex
.
sampler
);
if
(
b
.
stage
.
testFlag
(
QRhiShaderResourceBinding
::
VertexStage
))
{
res
[
0
].
textures
.
feed
(
b
.
binding
,
texD
->
d
->
tex
);
res
[
0
].
samplers
.
feed
(
b
.
binding
,
samplerD
->
d
->
samplerState
);
QMetalTexture
*
texD
=
QRHI_RES
(
QMetalTexture
,
b
->
u
.
stex
.
tex
);
QMetalSampler
*
samplerD
=
QRHI_RES
(
QMetalSampler
,
b
->
u
.
stex
.
sampler
);
if
(
b
->
stage
.
testFlag
(
QRhiShaderResourceBinding
::
VertexStage
))
{
res
[
0
].
textures
.
feed
(
b
->
binding
,
texD
->
d
->
tex
);
res
[
0
].
samplers
.
feed
(
b
->
binding
,
samplerD
->
d
->
samplerState
);
}
if
(
b
.
stage
.
testFlag
(
QRhiShaderResourceBinding
::
FragmentStage
))
{
res
[
1
].
textures
.
feed
(
b
.
binding
,
texD
->
d
->
tex
);
res
[
1
].
samplers
.
feed
(
b
.
binding
,
samplerD
->
d
->
samplerState
);
if
(
b
->
stage
.
testFlag
(
QRhiShaderResourceBinding
::
FragmentStage
))
{
res
[
1
].
textures
.
feed
(
b
->
binding
,
texD
->
d
->
tex
);
res
[
1
].
samplers
.
feed
(
b
->
binding
,
samplerD
->
d
->
samplerState
);
}
}
break
;
...
...
@@ -617,12 +618,12 @@ void QRhiMetal::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
// do buffer writes, figure out if we need to rebind, and mark as in-use
for
(
int
i
=
0
,
ie
=
srbD
->
sortedBindings
.
count
();
i
!=
ie
;
++
i
)
{
const
QRhiShaderResourceBinding
&
b
(
srbD
->
sortedBindings
[
i
]);
const
QRhiShaderResourceBinding
Private
*
b
=
QRhiShaderResourceBindingPrivate
::
get
(
&
srbD
->
sortedBindings
[
i
]);
QMetalShaderResourceBindings
::
BoundResourceData
&
bd
(
srbD
->
boundResourceData
[
i
]);
switch
(
b
.
type
)
{
switch
(
b
->
type
)
{
case
QRhiShaderResourceBinding
::
UniformBuffer
:
{
QMetalBuffer
*
bufD
=
QRHI_RES
(
QMetalBuffer
,
b
.
ubuf
.
buf
);
QMetalBuffer
*
bufD
=
QRHI_RES
(
QMetalBuffer
,
b
->
u
.
ubuf
.
buf
);
Q_ASSERT
(
bufD
->
m_usage
.
testFlag
(
QRhiBuffer
::
UniformBuffer
));
executeBufferHostWritesForCurrentFrame
(
bufD
);
if
(
bufD
->
m_type
!=
QRhiBuffer
::
Immutable
)
...
...
@@ -636,8 +637,8 @@ void QRhiMetal::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
break
;
case
QRhiShaderResourceBinding
::
SampledTexture
:
{
QMetalTexture
*
texD
=
QRHI_RES
(
QMetalTexture
,
b
.
stex
.
tex
);
QMetalSampler
*
samplerD
=
QRHI_RES
(
QMetalSampler
,
b
.
stex
.
sampler
);
QMetalTexture
*
texD
=
QRHI_RES
(
QMetalTexture
,
b
->
u
.
stex
.
tex
);
QMetalSampler
*
samplerD
=
QRHI_RES
(
QMetalSampler
,
b
->
u
.
stex
.
sampler
);
if
(
texD
->
generation
!=
bd
.
stex
.
texGeneration
||
samplerD
->
generation
!=
bd
.
stex
.
samplerGeneration
)
{
...
...
@@ -2212,22 +2213,22 @@ bool QMetalShaderResourceBindings::build()
return
QRhiShaderResourceBindingPrivate
::
get
(
&
a
)
->
binding
<
QRhiShaderResourceBindingPrivate
::
get
(
&
b
)
->
binding
;
});
if
(
!
sortedBindings
.
isEmpty
())
maxBinding
=
sortedBindings
.
last
()
.
binding
;
maxBinding
=
QRhiShaderResourceBindingPrivate
::
get
(
&
sortedBindings
.
last
()
)
->
binding
;
else
maxBinding
=
-
1
;
boundResourceData
.
resize
(
sortedBindings
.
count
());
for
(
int
i
=
0
,
ie
=
sortedBindings
.
count
();
i
!=
ie
;
++
i
)
{
const
QRhiShaderResourceBinding
&
b
(
sortedBindings
[
i
]);
const
QRhiShaderResourceBinding
Private
*
b
=
QRhiShaderResourceBindingPrivate
::
get
(
&
sortedBindings
[
i
]);
QMetalShaderResourceBindings
::
BoundResourceData
&
bd
(
boundResourceData
[
i
]);
switch
(
b
.
type
)
{
switch
(
b
->
type
)
{
case
QRhiShaderResourceBinding
::
UniformBuffer
:
bd
.
ubuf
.
generation
=
QRHI_RES
(
QMetalBuffer
,
b
.
ubuf
.
buf
)
->
generation
;
bd
.
ubuf
.
generation
=
QRHI_RES
(
QMetalBuffer
,
b
->
u
.
ubuf
.
buf
)
->
generation
;
break
;
case
QRhiShaderResourceBinding
::
SampledTexture
:
bd
.
stex
.
texGeneration
=
QRHI_RES
(
QMetalTexture
,
b
.
stex
.
tex
)
->
generation
;
bd
.
stex
.
samplerGeneration
=
QRHI_RES
(
QMetalSampler
,
b
.
stex
.
sampler
)
->
generation
;
bd
.
stex
.
texGeneration
=
QRHI_RES
(
QMetalTexture
,
b
->
u
.
stex
.
tex
)
->
generation
;
bd
.
stex
.
samplerGeneration
=
QRHI_RES
(
QMetalSampler
,
b
->
u
.
stex
.
sampler
)
->
generation
;
break
;
default:
Q_UNREACHABLE
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment