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
989c155b
Commit
989c155b
authored
Oct 29, 2018
by
Laszlo Agocs
Browse files
d3d: Move rtv and dsv out from renderpass
...as that's the wrong place to have them.
parent
b3ddf15f
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/rhi/qrhid3d11.cpp
View file @
989c155b
...
...
@@ -408,8 +408,8 @@ QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain)
currentFrameSlot
=
swapChainD
->
currentFrame
;
swapChainD
->
rt
.
d
.
pixelSize
=
swapChainD
->
pixelSize
;
swapChainD
->
rt
.
d
.
rp
.
rtv
[
0
]
=
swapChainD
->
rtv
[
currentFrameSlot
];
swapChainD
->
rt
.
d
.
rp
.
dsv
=
swapChainD
->
ds
?
swapChainD
->
ds
->
dsv
:
nullptr
;
swapChainD
->
rt
.
d
.
rtv
[
0
]
=
swapChainD
->
rtv
[
currentFrameSlot
];
swapChainD
->
rt
.
d
.
dsv
=
swapChainD
->
ds
?
swapChainD
->
ds
->
dsv
:
nullptr
;
return
QRhi
::
FrameOpSuccess
;
}
...
...
@@ -702,8 +702,6 @@ void QRhiD3D11::executeCommandBuffer(QD3D11CommandBuffer *cbD)
case
QD3D11CommandBuffer
::
Command
::
SetRenderTarget
:
{
QRhiRenderTarget
*
rt
=
cmd
.
args
.
setRenderTarget
.
rt
;
const
QD3D11RenderPass
*
rp
=
QRHI_RES
(
const
QD3D11RenderPass
,
rt
->
renderPass
());
Q_ASSERT
(
rp
);
// The new output cannot be bound as input from the previous frame,
// otherwise the debug layer complains. Avoid this.
const
int
nullsrvCount
=
qMax
(
contextState
.
vsLastActiveSrvBinding
,
contextState
.
fsLastActiveSrvBinding
)
+
1
;
...
...
@@ -714,16 +712,15 @@ void QRhiD3D11::executeCommandBuffer(QD3D11CommandBuffer *cbD)
context
->
VSSetShaderResources
(
0
,
nullsrvs
.
count
(),
nullsrvs
.
constData
());
context
->
PSSetShaderResources
(
0
,
nullsrvs
.
count
(),
nullsrvs
.
constData
());
QD3D11BasicRenderTargetData
*
rtD
=
basicRtData
(
rt
);
context
->
OMSetRenderTargets
(
rtD
->
colorAttCount
,
rtD
->
colorAttCount
?
r
p
->
rtv
:
nullptr
,
r
p
->
dsv
);
context
->
OMSetRenderTargets
(
rtD
->
colorAttCount
,
rtD
->
colorAttCount
?
r
tD
->
rtv
:
nullptr
,
r
tD
->
dsv
);
}
break
;
case
QD3D11CommandBuffer
::
Command
::
Clear
:
{
const
QD3D11Render
Pass
*
r
p
=
QRHI_RES
(
const
QD3D11RenderPass
,
cmd
.
args
.
clear
.
rt
->
renderPass
()
);
QD3D11
Basic
Render
TargetData
*
r
tD
=
basicRtData
(
cmd
.
args
.
clear
.
rt
);
if
(
cmd
.
args
.
clear
.
mask
&
QD3D11CommandBuffer
::
Command
::
Color
)
{
QD3D11BasicRenderTargetData
*
rtD
=
basicRtData
(
cmd
.
args
.
clear
.
rt
);
for
(
int
i
=
0
;
i
<
rtD
->
colorAttCount
;
++
i
)
context
->
ClearRenderTargetView
(
r
p
->
rtv
[
i
],
cmd
.
args
.
clear
.
c
);
context
->
ClearRenderTargetView
(
r
tD
->
rtv
[
i
],
cmd
.
args
.
clear
.
c
);
}
uint
ds
=
0
;
if
(
cmd
.
args
.
clear
.
mask
&
QD3D11CommandBuffer
::
Command
::
Depth
)
...
...
@@ -731,7 +728,7 @@ void QRhiD3D11::executeCommandBuffer(QD3D11CommandBuffer *cbD)
if
(
cmd
.
args
.
clear
.
mask
&
QD3D11CommandBuffer
::
Command
::
Stencil
)
ds
|=
D3D11_CLEAR_STENCIL
;
if
(
ds
)
context
->
ClearDepthStencilView
(
r
p
->
dsv
,
ds
,
cmd
.
args
.
clear
.
d
,
cmd
.
args
.
clear
.
s
);
context
->
ClearDepthStencilView
(
r
tD
->
dsv
,
ds
,
cmd
.
args
.
clear
.
d
,
cmd
.
args
.
clear
.
s
);
}
break
;
case
QD3D11CommandBuffer
::
Command
::
Viewport
:
...
...
@@ -1176,8 +1173,6 @@ bool QD3D11Sampler::build()
QD3D11RenderPass
::
QD3D11RenderPass
(
QRhiImplementation
*
rhi
)
:
QRhiRenderPass
(
rhi
)
{
for
(
int
i
=
0
;
i
<
MAX_COLOR_ATTACHMENTS
;
++
i
)
rtv
[
i
]
=
nullptr
;
}
void
QD3D11RenderPass
::
release
()
...
...
@@ -1217,7 +1212,7 @@ QD3D11TextureRenderTarget::QD3D11TextureRenderTarget(QRhiImplementation *rhi,
:
QRhiTextureRenderTarget
(
rhi
,
desc
,
flags
),
d
(
rhi
)
{
for
(
int
i
=
0
;
i
<
QD3D11Render
Pass
::
MAX_COLOR_ATTACHMENTS
;
++
i
)
for
(
int
i
=
0
;
i
<
QD3D11
Basic
Render
TargetData
::
MAX_COLOR_ATTACHMENTS
;
++
i
)
rtv
[
i
]
=
nullptr
;
}
...
...
@@ -1232,7 +1227,7 @@ void QD3D11TextureRenderTarget::release()
dsv
=
nullptr
;
}
for
(
int
i
=
0
;
i
<
QD3D11Render
Pass
::
MAX_COLOR_ATTACHMENTS
;
++
i
)
{
for
(
int
i
=
0
;
i
<
QD3D11
Basic
Render
TargetData
::
MAX_COLOR_ATTACHMENTS
;
++
i
)
{
if
(
rtv
[
i
])
{
rtv
[
i
]
->
Release
();
rtv
[
i
]
=
nullptr
;
...
...
@@ -1301,10 +1296,10 @@ bool QD3D11TextureRenderTarget::build()
d
.
dsAttCount
=
0
;
}
for
(
int
i
=
0
;
i
<
QD3D11Render
Pass
::
MAX_COLOR_ATTACHMENTS
;
++
i
)
d
.
rp
.
rtv
[
i
]
=
i
<
d
.
colorAttCount
?
rtv
[
i
]
:
nullptr
;
for
(
int
i
=
0
;
i
<
QD3D11
Basic
Render
TargetData
::
MAX_COLOR_ATTACHMENTS
;
++
i
)
d
.
rtv
[
i
]
=
i
<
d
.
colorAttCount
?
rtv
[
i
]
:
nullptr
;
d
.
rp
.
dsv
=
dsv
;
d
.
dsv
=
dsv
;
return
true
;
}
...
...
src/rhi/qrhid3d11_p.h
View file @
989c155b
...
...
@@ -104,20 +104,25 @@ struct QD3D11RenderPass : public QRhiRenderPass
{
QD3D11RenderPass
(
QRhiImplementation
*
rhi
);
void
release
()
override
;
static
const
int
MAX_COLOR_ATTACHMENTS
=
8
;
ID3D11RenderTargetView
*
rtv
[
MAX_COLOR_ATTACHMENTS
];
ID3D11DepthStencilView
*
dsv
=
nullptr
;
};
struct
QD3D11BasicRenderTargetData
{
QD3D11BasicRenderTargetData
(
QRhiImplementation
*
rhi
)
:
rp
(
rhi
)
{
}
QD3D11BasicRenderTargetData
(
QRhiImplementation
*
rhi
)
:
rp
(
rhi
)
{
for
(
int
i
=
0
;
i
<
MAX_COLOR_ATTACHMENTS
;
++
i
)
rtv
[
i
]
=
nullptr
;
}
QD3D11RenderPass
rp
;
QSize
pixelSize
;
int
colorAttCount
=
0
;
int
dsAttCount
=
0
;
static
const
int
MAX_COLOR_ATTACHMENTS
=
8
;
ID3D11RenderTargetView
*
rtv
[
MAX_COLOR_ATTACHMENTS
];
ID3D11DepthStencilView
*
dsv
=
nullptr
;
};
struct
QD3D11ReferenceRenderTarget
:
public
QRhiReferenceRenderTarget
...
...
@@ -141,7 +146,7 @@ struct QD3D11TextureRenderTarget : public QRhiTextureRenderTarget
const
QRhiRenderPass
*
renderPass
()
const
override
;
QD3D11BasicRenderTargetData
d
;
ID3D11RenderTargetView
*
rtv
[
QD3D11Render
Pass
::
MAX_COLOR_ATTACHMENTS
];
ID3D11RenderTargetView
*
rtv
[
QD3D11
Basic
Render
TargetData
::
MAX_COLOR_ATTACHMENTS
];
bool
ownsDsv
=
false
;
ID3D11DepthStencilView
*
dsv
=
nullptr
;
friend
class
QRhiD3D11
;
...
...
src/rhi/qrhimetal_p.h
View file @
989c155b
...
...
@@ -99,8 +99,6 @@ struct QMetalSampler : public QRhiSampler
friend
class
QRhiMetal
;
};
struct
QMetalRenderPassData
;
struct
QMetalRenderPass
:
public
QRhiRenderPass
{
QMetalRenderPass
(
QRhiImplementation
*
rhi
);
...
...
todo.txt
View file @
989c155b
make rp dep in ps less invasive (rethink how QRhiRenderPass is handled)
d3d: why duplicate rtv/dsv in rp?
gl: offscreensurface ownership not taken (fix examples)
figure out what's up with instance step rate
mtl: buffer logic is borked
...
...
@@ -43,6 +42,7 @@ bytecode (fxc/dxc) for d3d?
bytecode for metal?
+++ done
d3d: why rtv/dsv in rp -> should be in rtD
new "minimal" example
cubemap face as target
test mrt
...
...
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