mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-11 01:24:12 +01:00
[d3d11] Use EmitCs for general setup and synchronization methods
This commit is contained in:
parent
2dd24a14d2
commit
4d17b1752f
@ -15,8 +15,7 @@ namespace dxvk {
|
||||
: m_parent(parent),
|
||||
m_device(device) {
|
||||
m_context = m_device->createContext();
|
||||
m_context->beginRecording(
|
||||
m_device->createCommandList());
|
||||
|
||||
// Create default state objects. We won't ever return them
|
||||
// to the application, but we'll use them to apply state.
|
||||
Com<ID3D11BlendState> defaultBlendState;
|
||||
@ -31,22 +30,32 @@ namespace dxvk {
|
||||
// Apply default state to the context. This is required
|
||||
// in order to initialize the DXVK contex properly.
|
||||
m_defaultBlendState = static_cast<D3D11BlendState*> (defaultBlendState.ptr());
|
||||
m_defaultBlendState->BindToContext(m_context, 0xFFFFFFFF);
|
||||
|
||||
m_defaultDepthStencilState = static_cast<D3D11DepthStencilState*>(defaultDepthStencilState.ptr());
|
||||
m_defaultDepthStencilState->BindToContext(m_context);
|
||||
|
||||
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
|
||||
// when the application binds null to a sampler slot.
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -568,7 +568,7 @@ namespace dxvk {
|
||||
template<typename Cmd>
|
||||
void EmitCs(Cmd&& command) {
|
||||
// TODO push to CS chunk
|
||||
command.execute(m_context.ptr());
|
||||
command(m_context.ptr());
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -41,12 +41,14 @@ namespace dxvk {
|
||||
m_parent->FlushInitContext();
|
||||
m_drawCount = 0;
|
||||
|
||||
m_device->submitCommandList(
|
||||
m_context->endRecording(),
|
||||
EmitCs([dev = m_device] (DxvkContext* ctx) {
|
||||
dev->submitCommandList(
|
||||
ctx->endRecording(),
|
||||
nullptr, nullptr);
|
||||
|
||||
m_context->beginRecording(
|
||||
m_device->createCommandList());
|
||||
ctx->beginRecording(
|
||||
dev->createCommandList());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user