mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-14 04:29:15 +01:00
[dxvk] More convenient command list assignment API
This commit is contained in:
parent
27905d0711
commit
4e39ef859b
@ -11,8 +11,8 @@ namespace dxvk {
|
||||
: m_parent(parent),
|
||||
m_device(device) {
|
||||
m_context = m_device->createContext();
|
||||
m_cmdList = m_device->createCommandList();
|
||||
m_context->beginRecording(m_cmdList);
|
||||
m_context->beginRecording(
|
||||
m_device->createCommandList());
|
||||
}
|
||||
|
||||
|
||||
@ -55,12 +55,12 @@ namespace dxvk {
|
||||
|
||||
void D3D11DeviceContext::Flush() {
|
||||
if (m_type == D3D11_DEVICE_CONTEXT_IMMEDIATE) {
|
||||
m_context->endRecording();
|
||||
m_device->submitCommandList(
|
||||
m_cmdList, nullptr, nullptr);
|
||||
m_context->endRecording(),
|
||||
nullptr, nullptr);
|
||||
|
||||
m_cmdList = m_device->createCommandList();
|
||||
m_context->beginRecording(m_cmdList);
|
||||
m_context->beginRecording(
|
||||
m_device->createCommandList());
|
||||
} else {
|
||||
Logger::err("D3D11DeviceContext::Flush: Not supported on deferred context");
|
||||
}
|
||||
|
@ -545,7 +545,6 @@ namespace dxvk {
|
||||
|
||||
Rc<DxvkDevice> m_device;
|
||||
Rc<DxvkContext> m_context;
|
||||
Rc<DxvkCommandList> m_cmdList;
|
||||
|
||||
D3D11ContextState m_state;
|
||||
|
||||
|
@ -9,7 +9,8 @@ namespace dxvk {
|
||||
HWND window,
|
||||
UINT bufferWidth,
|
||||
UINT bufferHeight)
|
||||
: m_device(device) {
|
||||
: m_device (device),
|
||||
m_context (device->createContext()) {
|
||||
|
||||
// Create Vulkan surface for the window
|
||||
HINSTANCE instance = reinterpret_cast<HINSTANCE>(
|
||||
@ -32,10 +33,6 @@ namespace dxvk {
|
||||
m_acquireSync = m_device->createSemaphore();
|
||||
m_presentSync = m_device->createSemaphore();
|
||||
|
||||
// Create context and a command list
|
||||
m_context = m_device->createContext();
|
||||
m_commandList = m_device->createCommandList();
|
||||
|
||||
// Set up context state. The shader bindings and the
|
||||
// constant state objects will never be modified.
|
||||
m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, createVertexShader());
|
||||
@ -104,10 +101,11 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxgiPresenter::presentImage(const Rc<DxvkImageView>& view) {
|
||||
m_context->beginRecording(
|
||||
m_device->createCommandList());
|
||||
|
||||
auto framebuffer = m_swapchain->getFramebuffer(m_acquireSync);
|
||||
auto framebufferSize = framebuffer->size();
|
||||
|
||||
m_context->beginRecording(m_commandList);
|
||||
m_context->bindFramebuffer(framebuffer);
|
||||
|
||||
VkViewport viewport;
|
||||
@ -128,9 +126,9 @@ namespace dxvk {
|
||||
|
||||
// TODO bind back buffer as a shader resource
|
||||
m_context->draw(4, 1, 0, 0);
|
||||
m_context->endRecording();
|
||||
|
||||
m_device->submitCommandList(m_commandList,
|
||||
m_device->submitCommandList(
|
||||
m_context->endRecording(),
|
||||
m_acquireSync, m_presentSync);
|
||||
|
||||
m_swapchain->present(m_presentSync);
|
||||
|
@ -37,6 +37,7 @@ namespace dxvk {
|
||||
private:
|
||||
|
||||
Rc<DxvkDevice> m_device;
|
||||
Rc<DxvkContext> m_context;
|
||||
|
||||
Rc<DxvkSurface> m_surface;
|
||||
Rc<DxvkSwapchain> m_swapchain;
|
||||
@ -44,9 +45,6 @@ namespace dxvk {
|
||||
Rc<DxvkSemaphore> m_acquireSync;
|
||||
Rc<DxvkSemaphore> m_presentSync;
|
||||
|
||||
Rc<DxvkContext> m_context;
|
||||
Rc<DxvkCommandList> m_commandList;
|
||||
|
||||
Rc<DxvkShader> createVertexShader();
|
||||
Rc<DxvkShader> createFragmentShader();
|
||||
|
||||
|
@ -40,11 +40,11 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkContext::endRecording() {
|
||||
Rc<DxvkCommandList> DxvkContext::endRecording() {
|
||||
this->renderPassEnd();
|
||||
|
||||
m_cmd->endRecording();
|
||||
m_cmd = nullptr;
|
||||
return std::exchange(m_cmd, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,8 +44,9 @@ namespace dxvk {
|
||||
*
|
||||
* This will not change any context state
|
||||
* other than the active command list.
|
||||
* \returns Active command list
|
||||
*/
|
||||
void endRecording();
|
||||
Rc<DxvkCommandList> endRecording();
|
||||
|
||||
/**
|
||||
* \brief Sets framebuffer
|
||||
|
@ -76,8 +76,7 @@ public:
|
||||
VK_PRESENT_MODE_FIFO_KHR,
|
||||
VkExtent2D { 640, 480 },
|
||||
})),
|
||||
m_dxvkContext (m_dxvkDevice->createContext()),
|
||||
m_dxvkCommandList (m_dxvkDevice->createCommandList()) {
|
||||
m_dxvkContext (m_dxvkDevice->createContext()) {
|
||||
|
||||
m_dxvkContext->setInputAssemblyState(
|
||||
new DxvkInputAssemblyState(
|
||||
@ -135,7 +134,8 @@ public:
|
||||
auto fb = m_dxvkSwapchain->getFramebuffer(sync1);
|
||||
auto fbSize = fb->size();
|
||||
|
||||
m_dxvkContext->beginRecording(m_dxvkCommandList);
|
||||
m_dxvkContext->beginRecording(
|
||||
m_dxvkDevice->createCommandList());
|
||||
m_dxvkContext->bindFramebuffer(fb);
|
||||
|
||||
VkViewport viewport;
|
||||
@ -171,10 +171,9 @@ public:
|
||||
clearAttachment,
|
||||
clearArea);
|
||||
m_dxvkContext->draw(3, 1, 0, 0);
|
||||
m_dxvkContext->endRecording();
|
||||
|
||||
auto fence = m_dxvkDevice->submitCommandList(
|
||||
m_dxvkCommandList, sync1, sync2);
|
||||
m_dxvkContext->endRecording(), sync1, sync2);
|
||||
m_dxvkSwapchain->present(sync2);
|
||||
m_dxvkDevice->waitForIdle();
|
||||
}
|
||||
@ -187,7 +186,6 @@ private:
|
||||
Rc<DxvkSurface> m_dxvkSurface;
|
||||
Rc<DxvkSwapchain> m_dxvkSwapchain;
|
||||
Rc<DxvkContext> m_dxvkContext;
|
||||
Rc<DxvkCommandList> m_dxvkCommandList;
|
||||
|
||||
Rc<DxvkShader> m_dxvkVertexShader;
|
||||
Rc<DxvkShader> m_dxvkFragmentShader;
|
||||
|
Loading…
x
Reference in New Issue
Block a user