mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[dxvk] Command list now implements DxvkRecorder
This commit is contained in:
parent
d97ccb82d6
commit
6e057b2b53
@ -74,4 +74,68 @@ namespace dxvk {
|
||||
m_resources.reset();
|
||||
}
|
||||
|
||||
|
||||
void DxvkCommandList::cmdBeginRenderPass(
|
||||
const VkRenderPassBeginInfo* pRenderPassBegin,
|
||||
VkSubpassContents contents) {
|
||||
m_vkd->vkCmdBeginRenderPass(m_buffer,
|
||||
pRenderPassBegin, contents);
|
||||
}
|
||||
|
||||
|
||||
void DxvkCommandList::cmdBindPipeline(
|
||||
VkPipelineBindPoint pipelineBindPoint,
|
||||
VkPipeline pipeline) {
|
||||
m_vkd->vkCmdBindPipeline(m_buffer,
|
||||
pipelineBindPoint, pipeline);
|
||||
}
|
||||
|
||||
|
||||
void DxvkCommandList::cmdClearAttachments(
|
||||
uint32_t attachmentCount,
|
||||
const VkClearAttachment* pAttachments,
|
||||
uint32_t rectCount,
|
||||
const VkClearRect* pRects) {
|
||||
m_vkd->vkCmdClearAttachments(m_buffer,
|
||||
attachmentCount, pAttachments,
|
||||
rectCount, pRects);
|
||||
}
|
||||
|
||||
|
||||
void DxvkCommandList::cmdDispatch(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t z) {
|
||||
m_vkd->vkCmdDispatch(m_buffer, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
void DxvkCommandList::cmdDraw(
|
||||
uint32_t vertexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstVertex,
|
||||
uint32_t firstInstance) {
|
||||
m_vkd->vkCmdDraw(m_buffer,
|
||||
vertexCount, instanceCount,
|
||||
firstVertex, firstInstance);
|
||||
}
|
||||
|
||||
|
||||
void DxvkCommandList::cmdDrawIndexed(
|
||||
uint32_t indexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstIndex,
|
||||
uint32_t vertexOffset,
|
||||
uint32_t firstInstance) {
|
||||
m_vkd->vkCmdDrawIndexed(m_buffer,
|
||||
indexCount, instanceCount,
|
||||
firstIndex, vertexOffset,
|
||||
firstInstance);
|
||||
}
|
||||
|
||||
|
||||
void DxvkCommandList::cmdEndRenderPass() {
|
||||
m_vkd->vkCmdEndRenderPass(m_buffer);
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
#include <unordered_set>
|
||||
|
||||
#include "dxvk_lifetime.h"
|
||||
#include "dxvk_recorder.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
@ -15,7 +16,7 @@ namespace dxvk {
|
||||
* When the command list has completed execution, resources that
|
||||
* are no longer used may get destroyed.
|
||||
*/
|
||||
class DxvkCommandList : public RcObject {
|
||||
class DxvkCommandList : public DxvkRecorder {
|
||||
|
||||
public:
|
||||
|
||||
@ -32,8 +33,21 @@ namespace dxvk {
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
void beginRecording();
|
||||
void endRecording();
|
||||
/**
|
||||
* \brief Begins recording
|
||||
*
|
||||
* Resets the command buffer and
|
||||
* begins command buffer recording.
|
||||
*/
|
||||
void beginRecording() final;
|
||||
|
||||
/**
|
||||
* \brief Ends recording
|
||||
*
|
||||
* Ends command buffer recording, making
|
||||
* the command list ready for submission.
|
||||
*/
|
||||
void endRecording() final;
|
||||
|
||||
/**
|
||||
* \brief Adds a resource to track
|
||||
@ -44,7 +58,7 @@ namespace dxvk {
|
||||
* completed.
|
||||
*/
|
||||
void trackResource(
|
||||
const Rc<DxvkResource>& rc);
|
||||
const Rc<DxvkResource>& rc) final;
|
||||
|
||||
/**
|
||||
* \brief Resets the command list
|
||||
@ -54,7 +68,41 @@ namespace dxvk {
|
||||
* command list to the device, this method will be called once
|
||||
* the command list completes execution.
|
||||
*/
|
||||
void reset();
|
||||
void reset() final;
|
||||
|
||||
void cmdBeginRenderPass(
|
||||
const VkRenderPassBeginInfo* pRenderPassBegin,
|
||||
VkSubpassContents contents) final;
|
||||
|
||||
void cmdBindPipeline(
|
||||
VkPipelineBindPoint pipelineBindPoint,
|
||||
VkPipeline pipeline) final;
|
||||
|
||||
void cmdClearAttachments(
|
||||
uint32_t attachmentCount,
|
||||
const VkClearAttachment* pAttachments,
|
||||
uint32_t rectCount,
|
||||
const VkClearRect* pRects) final;
|
||||
|
||||
void cmdDispatch(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t z) final;
|
||||
|
||||
void cmdDraw(
|
||||
uint32_t vertexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstVertex,
|
||||
uint32_t firstInstance) final;
|
||||
|
||||
void cmdDrawIndexed(
|
||||
uint32_t indexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstIndex,
|
||||
uint32_t vertexOffset,
|
||||
uint32_t firstInstance) final;
|
||||
|
||||
void cmdEndRenderPass() final;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -3,8 +3,7 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkContext::DxvkContext(const Rc<vk::DeviceFn>& vkd)
|
||||
: m_vkd(vkd) {
|
||||
DxvkContext::DxvkContext() {
|
||||
TRACE(this);
|
||||
}
|
||||
|
||||
@ -15,10 +14,10 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxvkContext::beginRecording(
|
||||
const Rc<DxvkCommandList>& cmdList) {
|
||||
TRACE(this, cmdList);
|
||||
m_commandList = cmdList;
|
||||
m_commandList->beginRecording();
|
||||
const Rc<DxvkRecorder>& recorder) {
|
||||
TRACE(this, recorder);
|
||||
m_cmd = recorder;
|
||||
m_cmd->beginRecording();
|
||||
|
||||
// Make sure that we apply the current context state
|
||||
// to the command buffer when recording draw commands.
|
||||
@ -46,8 +45,8 @@ namespace dxvk {
|
||||
this->endRenderPass();
|
||||
|
||||
// Finalize the command list
|
||||
m_commandList->endRecording();
|
||||
m_commandList = nullptr;
|
||||
m_cmd->endRecording();
|
||||
m_cmd = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -57,10 +56,8 @@ namespace dxvk {
|
||||
const VkClearRect& clearArea) {
|
||||
this->flushGraphicsState();
|
||||
|
||||
m_vkd->vkCmdClearAttachments(
|
||||
m_commandList->handle(),
|
||||
1, &attachment,
|
||||
1, &clearArea);
|
||||
m_cmd->cmdClearAttachments(
|
||||
1, &attachment, 1, &clearArea);
|
||||
}
|
||||
|
||||
|
||||
@ -70,8 +67,7 @@ namespace dxvk {
|
||||
uint32_t wgCountZ) {
|
||||
this->flushComputeState();
|
||||
|
||||
m_vkd->vkCmdDispatch(
|
||||
m_commandList->handle(),
|
||||
m_cmd->cmdDispatch(
|
||||
wgCountX, wgCountY, wgCountZ);
|
||||
}
|
||||
|
||||
@ -83,12 +79,9 @@ namespace dxvk {
|
||||
uint32_t firstInstance) {
|
||||
this->flushGraphicsState();
|
||||
|
||||
m_vkd->vkCmdDraw(
|
||||
m_commandList->handle(),
|
||||
vertexCount,
|
||||
instanceCount,
|
||||
firstVertex,
|
||||
firstInstance);
|
||||
m_cmd->cmdDraw(
|
||||
vertexCount, instanceCount,
|
||||
firstVertex, firstInstance);
|
||||
}
|
||||
|
||||
|
||||
@ -100,12 +93,9 @@ namespace dxvk {
|
||||
uint32_t firstInstance) {
|
||||
this->flushGraphicsState();
|
||||
|
||||
m_vkd->vkCmdDrawIndexed(
|
||||
m_commandList->handle(),
|
||||
indexCount,
|
||||
instanceCount,
|
||||
firstIndex,
|
||||
vertexOffset,
|
||||
m_cmd->cmdDrawIndexed(
|
||||
indexCount, instanceCount,
|
||||
firstIndex, vertexOffset,
|
||||
firstInstance);
|
||||
}
|
||||
|
||||
@ -148,11 +138,9 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxvkContext::flushComputeState() {
|
||||
VkCommandBuffer cmd = m_commandList->handle();
|
||||
|
||||
if (m_state.c.flags.test(DxvkComputePipelineBit::PipelineDirty)
|
||||
&& m_state.c.pipeline != nullptr) {
|
||||
m_vkd->vkCmdBindPipeline(cmd,
|
||||
m_cmd->cmdBindPipeline(
|
||||
VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
m_state.c.pipeline->handle());
|
||||
}
|
||||
@ -184,7 +172,7 @@ namespace dxvk {
|
||||
info.clearValueCount = 0;
|
||||
info.pClearValues = nullptr;
|
||||
|
||||
m_vkd->vkCmdBeginRenderPass(m_commandList->handle(), &info, VK_SUBPASS_CONTENTS_INLINE);
|
||||
m_cmd->cmdBeginRenderPass(&info, VK_SUBPASS_CONTENTS_INLINE);
|
||||
m_state.g.flags.set(DxvkGraphicsPipelineBit::RenderPassBound);
|
||||
}
|
||||
|
||||
@ -192,7 +180,7 @@ namespace dxvk {
|
||||
void DxvkContext::endRenderPass() {
|
||||
TRACE(this);
|
||||
|
||||
m_vkd->vkCmdEndRenderPass(m_commandList->handle());
|
||||
m_cmd->cmdEndRenderPass();
|
||||
m_state.g.flags.clr(DxvkGraphicsPipelineBit::RenderPassBound);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "dxvk_cmdlist.h"
|
||||
#include "dxvk_context_state.h"
|
||||
#include "dxvk_deferred.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
@ -16,7 +17,7 @@ namespace dxvk {
|
||||
|
||||
public:
|
||||
|
||||
DxvkContext(const Rc<vk::DeviceFn>& vkd);
|
||||
DxvkContext();
|
||||
~DxvkContext();
|
||||
|
||||
/**
|
||||
@ -25,10 +26,10 @@ namespace dxvk {
|
||||
* Begins recording a command list. This does
|
||||
* not alter any context state other than the
|
||||
* active command list.
|
||||
* \param [in] cmdList Target command list
|
||||
* \param [in] recorder Target recorder
|
||||
*/
|
||||
void beginRecording(
|
||||
const Rc<DxvkCommandList>& cmdList);
|
||||
const Rc<DxvkRecorder>& recorder);
|
||||
|
||||
/**
|
||||
* \brief Ends command buffer recording
|
||||
@ -124,9 +125,8 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
Rc<vk::DeviceFn> m_vkd;
|
||||
Rc<DxvkCommandList> m_commandList;
|
||||
DxvkContextState m_state;
|
||||
Rc<DxvkRecorder> m_cmd;
|
||||
DxvkContextState m_state;
|
||||
|
||||
void flushComputeState();
|
||||
void flushGraphicsState();
|
||||
|
@ -35,7 +35,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
Rc<DxvkContext> DxvkDevice::createContext() {
|
||||
return new DxvkContext(m_vkd);
|
||||
return new DxvkContext();
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,11 @@ namespace dxvk {
|
||||
virtual void beginRecording() = 0;
|
||||
virtual void endRecording() = 0;
|
||||
|
||||
virtual void trackResource(
|
||||
const Rc<DxvkResource>& rc) = 0;
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
virtual void cmdBeginRenderPass(
|
||||
const VkRenderPassBeginInfo* pRenderPassBegin,
|
||||
VkSubpassContents contents) = 0;
|
||||
@ -54,12 +59,7 @@ namespace dxvk {
|
||||
uint32_t vertexOffset,
|
||||
uint32_t firstInstance) = 0;
|
||||
|
||||
virtual void cmdEndRenderPass();
|
||||
|
||||
virtual void trackResource(
|
||||
const Rc<DxvkResource>& rc) = 0;
|
||||
|
||||
virtual void reset() = 0;
|
||||
virtual void cmdEndRenderPass() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user