Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qtrhi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Laszlo Agocs
qtrhi
Commits
c47c3655
Commit
c47c3655
authored
Dec 23, 2018
by
Laszlo Agocs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an rt flag to preserve depth-stencil
parent
f349d345
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
15 deletions
+27
-15
src/rhi/qrhi.h
src/rhi/qrhi.h
+2
-1
src/rhi/qrhid3d11.cpp
src/rhi/qrhid3d11.cpp
+5
-5
src/rhi/qrhigles2.cpp
src/rhi/qrhigles2.cpp
+5
-3
src/rhi/qrhimetal.mm
src/rhi/qrhimetal.mm
+6
-2
src/rhi/qrhivulkan.cpp
src/rhi/qrhivulkan.cpp
+8
-4
src/rhi/qrhivulkan_p.h
src/rhi/qrhivulkan_p.h
+1
-0
No files found.
src/rhi/qrhi.h
View file @
c47c3655
...
...
@@ -606,7 +606,8 @@ class Q_RHI_EXPORT QRhiTextureRenderTarget : public QRhiRenderTarget
{
public:
enum
Flag
{
PreserveColorContents
=
1
<<
0
PreserveColorContents
=
1
<<
0
,
PreserveDepthStencilContents
=
1
<<
1
};
Q_DECLARE_FLAGS
(
Flags
,
Flag
)
...
...
src/rhi/qrhid3d11.cpp
View file @
c47c3655
...
...
@@ -978,10 +978,12 @@ void QRhiD3D11::beginPass(QRhiCommandBuffer *cb,
QD3D11CommandBuffer
*
cbD
=
QRHI_RES
(
QD3D11CommandBuffer
,
cb
);
bool
needsColorClear
=
true
;
bool
needsDsClear
=
true
;
QD3D11RenderTargetData
*
rtD
=
rtData
(
rt
);
if
(
rt
->
type
()
==
QRhiRenderTarget
::
RtTexture
)
{
QD3D11TextureRenderTarget
*
rtTex
=
QRHI_RES
(
QD3D11TextureRenderTarget
,
rt
);
needsColorClear
=
!
rtTex
->
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveColorContents
);
needsDsClear
=
!
rtTex
->
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveDepthStencilContents
);
}
cbD
->
currentTarget
=
rt
;
...
...
@@ -995,12 +997,10 @@ void QRhiD3D11::beginPass(QRhiCommandBuffer *cb,
clearCmd
.
cmd
=
QD3D11CommandBuffer
::
Command
::
Clear
;
clearCmd
.
args
.
clear
.
rt
=
rt
;
clearCmd
.
args
.
clear
.
mask
=
0
;
if
(
!
rtD
->
colorAttCount
)
needsColorClear
=
false
;
if
(
rtD
->
dsAttCount
)
clearCmd
.
args
.
clear
.
mask
|=
QD3D11CommandBuffer
::
Command
::
Depth
|
QD3D11CommandBuffer
::
Command
::
Stencil
;
if
(
needsColorClear
)
if
(
rtD
->
colorAttCount
&&
needsColorClear
)
clearCmd
.
args
.
clear
.
mask
|=
QD3D11CommandBuffer
::
Command
::
Color
;
if
(
rtD
->
dsAttCount
&&
needsDsClear
)
clearCmd
.
args
.
clear
.
mask
|=
QD3D11CommandBuffer
::
Command
::
Depth
|
QD3D11CommandBuffer
::
Command
::
Stencil
;
memcpy
(
clearCmd
.
args
.
clear
.
c
,
&
colorClearValue
.
rgba
,
sizeof
(
float
)
*
4
);
clearCmd
.
args
.
clear
.
d
=
depthStencilClearValue
.
d
;
...
...
src/rhi/qrhigles2.cpp
View file @
c47c3655
...
...
@@ -1377,6 +1377,7 @@ void QRhiGles2::beginPass(QRhiCommandBuffer *cb,
QGles2CommandBuffer
*
cbD
=
QRHI_RES
(
QGles2CommandBuffer
,
cb
);
bool
needsColorClear
=
true
;
bool
needsDsClear
=
true
;
QGles2BasicRenderTargetData
*
rtD
=
nullptr
;
QGles2CommandBuffer
::
Command
fbCmd
;
fbCmd
.
cmd
=
QGles2CommandBuffer
::
Command
::
BindFramebuffer
;
...
...
@@ -1390,6 +1391,7 @@ void QRhiGles2::beginPass(QRhiCommandBuffer *cb,
QGles2TextureRenderTarget
*
rtTex
=
QRHI_RES
(
QGles2TextureRenderTarget
,
rt
);
rtD
=
&
rtTex
->
d
;
needsColorClear
=
!
rtTex
->
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveColorContents
);
needsDsClear
=
!
rtTex
->
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveDepthStencilContents
);
fbCmd
.
args
.
bindFramebuffer
.
rt
=
rtTex
;
}
break
;
...
...
@@ -1405,10 +1407,10 @@ void QRhiGles2::beginPass(QRhiCommandBuffer *cb,
QGles2CommandBuffer
::
Command
clearCmd
;
clearCmd
.
cmd
=
QGles2CommandBuffer
::
Command
::
Clear
;
clearCmd
.
args
.
clear
.
mask
=
0
;
if
(
rtD
->
attCount
>
1
)
clearCmd
.
args
.
clear
.
mask
|=
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
;
if
(
needsColorClear
)
if
(
rtD
->
attCount
>
0
&&
needsColorClear
)
clearCmd
.
args
.
clear
.
mask
|=
GL_COLOR_BUFFER_BIT
;
if
(
rtD
->
attCount
>
1
&&
needsDsClear
)
clearCmd
.
args
.
clear
.
mask
|=
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
;
memcpy
(
clearCmd
.
args
.
clear
.
c
,
&
colorClearValue
.
rgba
,
sizeof
(
float
)
*
4
);
clearCmd
.
args
.
clear
.
d
=
depthStencilClearValue
.
d
;
...
...
src/rhi/qrhimetal.mm
View file @
c47c3655
...
...
@@ -1046,17 +1046,21 @@ void QRhiMetal::beginPass(QRhiCommandBuffer *cb,
switch
(
rt
->
type
())
{
case
QRhiRenderTarget
::
RtRef
:
rtD
=
QRHI_RES
(
QMetalReferenceRenderTarget
,
rt
)
->
d
;
cbD
->
d
->
currentPassRpDesc
=
d
->
createDefaultRenderPass
(
false
,
colorClearValue
,
depthStencilClearValue
);
cbD
->
d
->
currentPassRpDesc
=
d
->
createDefaultRenderPass
(
rtD
->
dsAttCount
,
colorClearValue
,
depthStencilClearValue
);
break
;
case
QRhiRenderTarget
::
RtTexture
:
{
QMetalTextureRenderTarget
*
rtTex
=
QRHI_RES
(
QMetalTextureRenderTarget
,
rt
);
rtD
=
rtTex
->
d
;
cbD
->
d
->
currentPassRpDesc
=
d
->
createDefaultRenderPass
(
false
,
colorClearValue
,
depthStencilClearValue
);
cbD
->
d
->
currentPassRpDesc
=
d
->
createDefaultRenderPass
(
rtD
->
dsAttCount
,
colorClearValue
,
depthStencilClearValue
);
if
(
rtTex
->
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveColorContents
))
{
for
(
int
i
=
0
;
i
<
rtD
->
colorAttCount
;
++
i
)
cbD
->
d
->
currentPassRpDesc
.
colorAttachments
[
i
].
loadAction
=
MTLLoadActionLoad
;
}
if
(
rtD
->
dsAttCount
&&
rtTex
->
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveDepthStencilContents
))
{
cbD
->
d
->
currentPassRpDesc
.
depthAttachment
.
loadAction
=
MTLLoadActionLoad
;
cbD
->
d
->
currentPassRpDesc
.
stencilAttachment
.
loadAction
=
MTLLoadActionLoad
;
}
}
break
;
default:
...
...
src/rhi/qrhivulkan.cpp
View file @
c47c3655
...
...
@@ -795,6 +795,7 @@ bool QRhiVulkan::createDefaultRenderPass(VkRenderPass *rp, bool hasDepthStencil,
bool
QRhiVulkan
::
createOffscreenRenderPass
(
VkRenderPass
*
rp
,
const
QVector
<
QRhiTextureRenderTargetDescription
::
ColorAttachment
>
&
colorAttachments
,
bool
preserveColor
,
bool
preserveDs
,
QRhiRenderBuffer
*
depthStencilBuffer
,
QRhiTexture
*
depthTexture
)
{
...
...
@@ -834,14 +835,16 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp,
:
QRHI_RES
(
QVkRenderBuffer
,
depthStencilBuffer
)
->
vkformat
;
const
VkSampleCountFlagBits
samples
=
depthTexture
?
QRHI_RES
(
QVkTexture
,
depthTexture
)
->
samples
:
QRHI_RES
(
QVkRenderBuffer
,
depthStencilBuffer
)
->
samples
;
const
VkAttachmentLoadOp
loadOp
=
preserveDs
?
VK_ATTACHMENT_LOAD_OP_LOAD
:
VK_ATTACHMENT_LOAD_OP_CLEAR
;
const
VkAttachmentStoreOp
storeOp
=
depthTexture
?
VK_ATTACHMENT_STORE_OP_STORE
:
VK_ATTACHMENT_STORE_OP_DONT_CARE
;
VkAttachmentDescription
attDesc
;
memset
(
&
attDesc
,
0
,
sizeof
(
attDesc
));
attDesc
.
format
=
dsFormat
;
attDesc
.
samples
=
samples
;
attDesc
.
loadOp
=
VK_ATTACHMENT_LOAD_OP_CLEAR
;
attDesc
.
storeOp
=
depthTexture
?
VK_ATTACHMENT_STORE_OP_STORE
:
VK_ATTACHMENT_STORE_OP_DONT_CARE
;
attDesc
.
stencilLoadOp
=
VK_ATTACHMENT_LOAD_OP_CLEAR
;
attDesc
.
stencilStoreOp
=
depthTexture
?
VK_ATTACHMENT_STORE_OP_STORE
:
VK_ATTACHMENT_STORE_OP_DONT_CARE
;
attDesc
.
loadOp
=
loadOp
;
attDesc
.
storeOp
=
storeOp
;
attDesc
.
stencilLoadOp
=
loadOp
;
attDesc
.
stencilStoreOp
=
storeOp
;
attDesc
.
initialLayout
=
VK_IMAGE_LAYOUT_UNDEFINED
;
attDesc
.
finalLayout
=
depthTexture
?
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
:
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
;
attDescs
.
append
(
attDesc
);
...
...
@@ -3625,6 +3628,7 @@ QRhiRenderPassDescriptor *QVkTextureRenderTarget::newCompatibleRenderPassDescrip
if
(
!
rhiD
->
createOffscreenRenderPass
(
&
rp
->
rp
,
m_desc
.
colorAttachments
,
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveColorContents
),
m_flags
.
testFlag
(
QRhiTextureRenderTarget
::
PreserveDepthStencilContents
),
m_desc
.
depthStencilBuffer
,
m_desc
.
depthTexture
))
{
...
...
src/rhi/qrhivulkan_p.h
View file @
c47c3655
...
...
@@ -406,6 +406,7 @@ public:
bool
createOffscreenRenderPass
(
VkRenderPass
*
rp
,
const
QVector
<
QRhiTextureRenderTargetDescription
::
ColorAttachment
>
&
colorAttachments
,
bool
preserveColor
,
bool
preserveDs
,
QRhiRenderBuffer
*
depthStencilBuffer
,
QRhiTexture
*
depthTexture
);
bool
ensurePipelineCache
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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