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