mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[d3d11] Move framebuffer creation out of OMSetRenderTargets
This might be useful when restoring context state.
This commit is contained in:
parent
b469cfac0b
commit
82ac381919
@ -1767,38 +1767,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
m_state.om.depthStencilView = static_cast<D3D11DepthStencilView*>(pDepthStencilView);
|
m_state.om.depthStencilView = static_cast<D3D11DepthStencilView*>(pDepthStencilView);
|
||||||
|
|
||||||
// NOTE According to the Microsoft docs, we are supposed to
|
BindFramebuffer();
|
||||||
// unbind overlapping shader resource views. Since this comes
|
|
||||||
// with a large performance penalty we'll ignore this until an
|
|
||||||
// application actually relies on this behaviour.
|
|
||||||
DxvkRenderTargets attachments;
|
|
||||||
|
|
||||||
// D3D11 doesn't have the concept of a framebuffer object,
|
|
||||||
// so we'll just create a new one every time the render
|
|
||||||
// target bindings are updated. Set up the attachments.
|
|
||||||
if (ppRenderTargetViews != nullptr || pDepthStencilView != nullptr) {
|
|
||||||
for (UINT i = 0; i < m_state.om.renderTargetViews.size(); i++) {
|
|
||||||
if (m_state.om.renderTargetViews.at(i) != nullptr) {
|
|
||||||
attachments.setColorTarget(i,
|
|
||||||
m_state.om.renderTargetViews.at(i)->GetImageView(),
|
|
||||||
m_state.om.renderTargetViews.at(i)->GetRenderLayout());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_state.om.depthStencilView != nullptr) {
|
|
||||||
attachments.setDepthTarget(
|
|
||||||
m_state.om.depthStencilView->GetImageView(),
|
|
||||||
m_state.om.depthStencilView->GetRenderLayout());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and bind the framebuffer object to the context
|
|
||||||
EmitCs([attachments, dev = m_device] (DxvkContext* ctx) {
|
|
||||||
Rc<DxvkFramebuffer> framebuffer = nullptr;
|
|
||||||
if (attachments.hasAttachments())
|
|
||||||
framebuffer = dev->createFramebuffer(attachments);
|
|
||||||
ctx->bindFramebuffer(framebuffer);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2075,6 +2044,40 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D11DeviceContext::BindFramebuffer() {
|
||||||
|
// NOTE According to the Microsoft docs, we are supposed to
|
||||||
|
// unbind overlapping shader resource views. Since this comes
|
||||||
|
// with a large performance penalty we'll ignore this until an
|
||||||
|
// application actually relies on this behaviour.
|
||||||
|
DxvkRenderTargets attachments;
|
||||||
|
|
||||||
|
// D3D11 doesn't have the concept of a framebuffer object,
|
||||||
|
// so we'll just create a new one every time the render
|
||||||
|
// target bindings are updated. Set up the attachments.
|
||||||
|
for (UINT i = 0; i < m_state.om.renderTargetViews.size(); i++) {
|
||||||
|
if (m_state.om.renderTargetViews.at(i) != nullptr) {
|
||||||
|
attachments.setColorTarget(i,
|
||||||
|
m_state.om.renderTargetViews.at(i)->GetImageView(),
|
||||||
|
m_state.om.renderTargetViews.at(i)->GetRenderLayout());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_state.om.depthStencilView != nullptr) {
|
||||||
|
attachments.setDepthTarget(
|
||||||
|
m_state.om.depthStencilView->GetImageView(),
|
||||||
|
m_state.om.depthStencilView->GetRenderLayout());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create and bind the framebuffer object to the context
|
||||||
|
EmitCs([attachments, dev = m_device] (DxvkContext* ctx) {
|
||||||
|
Rc<DxvkFramebuffer> framebuffer = nullptr;
|
||||||
|
if (attachments.hasAttachments())
|
||||||
|
framebuffer = dev->createFramebuffer(attachments);
|
||||||
|
ctx->bindFramebuffer(framebuffer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D11DeviceContext::BindConstantBuffers(
|
void D3D11DeviceContext::BindConstantBuffers(
|
||||||
DxbcProgramType ShaderStage,
|
DxbcProgramType ShaderStage,
|
||||||
D3D11ConstantBufferBindings& Bindings,
|
D3D11ConstantBufferBindings& Bindings,
|
||||||
@ -2323,6 +2326,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
void D3D11DeviceContext::RestoreState() {
|
void D3D11DeviceContext::RestoreState() {
|
||||||
Logger::err("D3D11DeviceContext::RestoreState: Not implemented");
|
Logger::err("D3D11DeviceContext::RestoreState: Not implemented");
|
||||||
|
|
||||||
|
BindFramebuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -527,6 +527,8 @@ namespace dxvk {
|
|||||||
D3D11ContextState m_state;
|
D3D11ContextState m_state;
|
||||||
uint64_t m_drawCount = 0;
|
uint64_t m_drawCount = 0;
|
||||||
|
|
||||||
|
void BindFramebuffer();
|
||||||
|
|
||||||
void BindConstantBuffers(
|
void BindConstantBuffers(
|
||||||
DxbcProgramType ShaderStage,
|
DxbcProgramType ShaderStage,
|
||||||
D3D11ConstantBufferBindings& Bindings,
|
D3D11ConstantBufferBindings& Bindings,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user