1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 22:08:59 +01:00

[d3d11] Use EmitCs for general setup and synchronization methods

This commit is contained in:
Philip Rebohle 2018-01-20 18:01:43 +01:00
parent 2dd24a14d2
commit 4d17b1752f
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 32 additions and 21 deletions

View File

@ -15,8 +15,7 @@ namespace dxvk {
: m_parent(parent), : m_parent(parent),
m_device(device) { m_device(device) {
m_context = m_device->createContext(); m_context = m_device->createContext();
m_context->beginRecording(
m_device->createCommandList());
// Create default state objects. We won't ever return them // Create default state objects. We won't ever return them
// to the application, but we'll use them to apply state. // to the application, but we'll use them to apply state.
Com<ID3D11BlendState> defaultBlendState; Com<ID3D11BlendState> defaultBlendState;
@ -30,23 +29,33 @@ namespace dxvk {
// Apply default state to the context. This is required // Apply default state to the context. This is required
// in order to initialize the DXVK contex properly. // in order to initialize the DXVK contex properly.
m_defaultBlendState = static_cast<D3D11BlendState*>(defaultBlendState.ptr()); m_defaultBlendState = static_cast<D3D11BlendState*> (defaultBlendState.ptr());
m_defaultBlendState->BindToContext(m_context, 0xFFFFFFFF);
m_defaultDepthStencilState = static_cast<D3D11DepthStencilState*>(defaultDepthStencilState.ptr()); m_defaultDepthStencilState = static_cast<D3D11DepthStencilState*>(defaultDepthStencilState.ptr());
m_defaultDepthStencilState->BindToContext(m_context); m_defaultRasterizerState = static_cast<D3D11RasterizerState*> (defaultRasterizerState.ptr());
m_defaultRasterizerState = static_cast<D3D11RasterizerState*>(defaultRasterizerState.ptr());
m_defaultRasterizerState->BindToContext(m_context);
m_context->setBlendConstants(DxvkBlendConstants {
m_state.om.blendFactor[0], m_state.om.blendFactor[1],
m_state.om.blendFactor[2], m_state.om.blendFactor[3] });
m_context->setStencilReference(m_state.om.stencilRef);
// Create a default sampler that we're going to bind // Create a default sampler that we're going to bind
// when the application binds null to a sampler slot. // when the application binds null to a sampler slot.
m_defaultSampler = CreateDefaultSampler(); m_defaultSampler = CreateDefaultSampler();
EmitCs([
dev = m_device,
bsState = m_defaultBlendState,
dsState = m_defaultDepthStencilState,
rsState = m_defaultRasterizerState,
blendConst = DxvkBlendConstants {
m_state.om.blendFactor[0], m_state.om.blendFactor[1],
m_state.om.blendFactor[2], m_state.om.blendFactor[3] },
stencilRef = m_state.om.stencilRef
] (DxvkContext* ctx) {
ctx->beginRecording(dev->createCommandList());
bsState->BindToContext(ctx, 0xFFFFFFFF);
dsState->BindToContext(ctx);
rsState->BindToContext(ctx);
ctx->setBlendConstants (blendConst);
ctx->setStencilReference(stencilRef);
});
} }

View File

@ -568,7 +568,7 @@ namespace dxvk {
template<typename Cmd> template<typename Cmd>
void EmitCs(Cmd&& command) { void EmitCs(Cmd&& command) {
// TODO push to CS chunk // TODO push to CS chunk
command.execute(m_context.ptr()); command(m_context.ptr());
} }
}; };

View File

@ -41,12 +41,14 @@ namespace dxvk {
m_parent->FlushInitContext(); m_parent->FlushInitContext();
m_drawCount = 0; m_drawCount = 0;
m_device->submitCommandList( EmitCs([dev = m_device] (DxvkContext* ctx) {
m_context->endRecording(), dev->submitCommandList(
nullptr, nullptr); ctx->endRecording(),
nullptr, nullptr);
m_context->beginRecording( ctx->beginRecording(
m_device->createCommandList()); dev->createCommandList());
});
} }