1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Implement bindRenderTargets method

An alternative to manually creating a framebuffer object and binding
it via bindFramebuffer. Future optmizations can use this to bring
down the number of redundant render pass changes.
This commit is contained in:
Philip Rebohle 2018-04-15 01:09:53 +02:00
parent 56ce794438
commit d523405a5a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 47 additions and 6 deletions

View File

@ -2458,11 +2458,8 @@ namespace dxvk {
} }
// Create and bind the framebuffer object to the context // Create and bind the framebuffer object to the context
EmitCs([attachments, dev = m_device] (DxvkContext* ctx) { EmitCs([cAttachments = std::move(attachments)] (DxvkContext* ctx) {
Rc<DxvkFramebuffer> framebuffer = nullptr; ctx->bindRenderTargets(cAttachments);
if (attachments.hasAttachments())
framebuffer = dev->createFramebuffer(attachments);
ctx->bindFramebuffer(framebuffer);
}); });
} }

View File

@ -93,6 +93,39 @@ namespace dxvk {
if (fb != nullptr) { if (fb != nullptr) {
m_state.gp.state.msSampleCount = fb->sampleCount(); m_state.gp.state.msSampleCount = fb->sampleCount();
m_state.gp.state.omRenderPass = fb->renderPass(); m_state.gp.state.omRenderPass = fb->renderPass();
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
}
}
}
void DxvkContext::bindRenderTargets(const DxvkRenderTargets& targets) {
bool needsUpdate = false;
if (m_state.om.framebuffer != nullptr) {
const DxvkRenderTargets& active = m_state.om.framebuffer->renderTargets();
needsUpdate |= active.getDepthTarget().view != targets.getDepthTarget().view
|| active.getDepthTarget().layout != targets.getDepthTarget().layout;
for (uint32_t i = 0; i < MaxNumRenderTargets && !needsUpdate; i++) {
needsUpdate |= active.getColorTarget(i).view != targets.getColorTarget(i).view
|| active.getColorTarget(i).layout != targets.getColorTarget(i).layout;
}
} else {
needsUpdate = targets.hasAttachments();
}
if (needsUpdate) {
Rc<DxvkFramebuffer> fb = targets.hasAttachments()
? m_device->createFramebuffer(targets)
: nullptr;
if (fb != nullptr) {
m_state.gp.state.msSampleCount = fb->sampleCount();
m_state.gp.state.omRenderPass = fb->renderPass();
m_flags.set(DxvkContextFlag::GpDirtyPipelineState); m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
} }
} }

View File

@ -78,6 +78,17 @@ namespace dxvk {
void bindFramebuffer( void bindFramebuffer(
const Rc<DxvkFramebuffer>& fb); const Rc<DxvkFramebuffer>& fb);
/**
* \brief Sets render targets
*
* Creates a framebuffer on the fly if necessary
* and binds it using \c bindFramebuffer. Prefer
* this method over doing the same thing manually.
* \param [in] targets Render targets to bind
*/
void bindRenderTargets(
const DxvkRenderTargets& targets);
/** /**
* \brief Binds index buffer * \brief Binds index buffer
* *