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:
parent
56ce794438
commit
d523405a5a
@ -2458,11 +2458,8 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
// 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);
|
||||
EmitCs([cAttachments = std::move(attachments)] (DxvkContext* ctx) {
|
||||
ctx->bindRenderTargets(cAttachments);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,39 @@ namespace dxvk {
|
||||
if (fb != nullptr) {
|
||||
m_state.gp.state.msSampleCount = fb->sampleCount();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,17 @@ namespace dxvk {
|
||||
void bindFramebuffer(
|
||||
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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user