From 676b0cb4763a7879706ea7fe13c91ff0d7d94b3b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 11 Apr 2018 17:05:12 +0200 Subject: [PATCH] [dxvk] Added DxvkMetaClearObjects stub --- src/dxvk/dxvk_context.cpp | 30 ++++++++++++++++++++----- src/dxvk/dxvk_context.h | 40 +++++++++++++++++++++++++++++++-- src/dxvk/dxvk_device.cpp | 11 +++++---- src/dxvk/dxvk_device.h | 2 ++ src/dxvk/dxvk_meta_clear.cpp | 15 +++++++++++++ src/dxvk/dxvk_meta_clear.h | 43 ++++++++++++++++++++++++++++++++++++ src/dxvk/meson.build | 1 + 7 files changed, 131 insertions(+), 11 deletions(-) create mode 100644 src/dxvk/dxvk_meta_clear.cpp create mode 100644 src/dxvk/dxvk_meta_clear.h diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index d1b1c10b..cdf01c93 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -7,11 +7,13 @@ namespace dxvk { DxvkContext::DxvkContext( - const Rc& device, - const Rc& pipelineCache) - : m_device (device), - m_pipeCache (pipelineCache), - m_pipeMgr (new DxvkPipelineManager(device.ptr())) { } + const Rc& device, + const Rc& pipelineCache, + const Rc& metaClearObjects) + : m_device (device), + m_pipeCache (pipelineCache), + m_pipeMgr (new DxvkPipelineManager(device.ptr())), + m_metaClear (metaClearObjects) { } DxvkContext::~DxvkContext() { @@ -235,6 +237,15 @@ namespace dxvk { } + void DxvkContext::clearBufferView( + const Rc& bufferView, + VkDeviceSize offset, + VkDeviceSize length, + VkClearColorValue value) { + + } + + void DxvkContext::clearColorImage( const Rc& image, const VkClearColorValue& value, @@ -355,6 +366,15 @@ namespace dxvk { } + void DxvkContext::clearImageView( + const Rc& bufferView, + VkOffset3D offset, + VkExtent3D extent, + VkClearColorValue value) { + + } + + void DxvkContext::copyBuffer( const Rc& dstBuffer, VkDeviceSize dstOffset, diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 02b32ded..8682f2f5 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -6,6 +6,7 @@ #include "dxvk_context_state.h" #include "dxvk_data.h" #include "dxvk_event.h" +#include "dxvk_meta_clear.h" #include "dxvk_meta_resolve.h" #include "dxvk_pipecache.h" #include "dxvk_pipemanager.h" @@ -27,8 +28,9 @@ namespace dxvk { public: DxvkContext( - const Rc& device, - const Rc& pipelineCache); + const Rc& device, + const Rc& pipelineCache, + const Rc& metaClearObjects); ~DxvkContext(); /** @@ -165,6 +167,22 @@ namespace dxvk { VkDeviceSize length, uint32_t value); + /** + * \brief Clears a buffer view + * + * Unlike \c clearBuffer, this method can be used + * to clear a buffer view with format conversion. + * \param [in] bufferView The buffer view + * \param [in] offset Offset of the region to clear + * \param [in] length Extent of the region to clear + * \param [in] value The clear value + */ + void clearBufferView( + const Rc& bufferView, + VkDeviceSize offset, + VkDeviceSize length, + VkClearColorValue value); + /** * \brief Clears subresources of a color image * @@ -203,6 +221,23 @@ namespace dxvk { VkImageAspectFlags clearAspects, const VkClearValue& clearValue); + /** + * \brief Clears an image view + * + * Can be used to clear sub-regions of storage images + * that are not going to be used as render targets. + * Implicit format conversion will be applied. + * \param [in] bufferView The buffer view + * \param [in] offset Offset of the rect to clear + * \param [in] extent Extent of the rect to clear + * \param [in] value The clear value + */ + void clearImageView( + const Rc& bufferView, + VkOffset3D offset, + VkExtent3D extent, + VkClearColorValue value); + /** * \brief Copies data from one buffer to another * @@ -568,6 +603,7 @@ namespace dxvk { const Rc m_device; const Rc m_pipeCache; const Rc m_pipeMgr; + const Rc m_metaClear; Rc m_cmd; DxvkContextFlags m_flags; diff --git a/src/dxvk/dxvk_device.cpp b/src/dxvk/dxvk_device.cpp index 1ea4d01a..d6fb1d43 100644 --- a/src/dxvk/dxvk_device.cpp +++ b/src/dxvk/dxvk_device.cpp @@ -12,9 +12,10 @@ namespace dxvk { m_vkd (vkd), m_extensions (extensions), m_features (features), - m_memory (new DxvkMemoryAllocator(adapter, vkd)), - m_renderPassPool (new DxvkRenderPassPool (vkd)), - m_pipelineCache (new DxvkPipelineCache (vkd)), + m_memory (new DxvkMemoryAllocator (adapter, vkd)), + m_renderPassPool (new DxvkRenderPassPool (vkd)), + m_pipelineCache (new DxvkPipelineCache (vkd)), + m_metaClearObjects(new DxvkMetaClearObjects (vkd)), m_unboundResources(this), m_submissionQueue (this) { m_vkd->vkGetDeviceQueue(m_vkd->device(), @@ -98,7 +99,9 @@ namespace dxvk { Rc DxvkDevice::createContext() { - return new DxvkContext(this, m_pipelineCache); + return new DxvkContext(this, + m_pipelineCache, + m_metaClearObjects); } diff --git a/src/dxvk/dxvk_device.h b/src/dxvk/dxvk_device.h index 7236abdb..c7f44a46 100644 --- a/src/dxvk/dxvk_device.h +++ b/src/dxvk/dxvk_device.h @@ -9,6 +9,7 @@ #include "dxvk_framebuffer.h" #include "dxvk_image.h" #include "dxvk_memory.h" +#include "dxvk_meta_clear.h" #include "dxvk_pipecache.h" #include "dxvk_pipemanager.h" #include "dxvk_queue.h" @@ -310,6 +311,7 @@ namespace dxvk { Rc m_memory; Rc m_renderPassPool; Rc m_pipelineCache; + Rc m_metaClearObjects; DxvkUnboundResources m_unboundResources; diff --git a/src/dxvk/dxvk_meta_clear.cpp b/src/dxvk/dxvk_meta_clear.cpp new file mode 100644 index 00000000..071cde28 --- /dev/null +++ b/src/dxvk/dxvk_meta_clear.cpp @@ -0,0 +1,15 @@ +#include "dxvk_meta_clear.h" + +namespace dxvk { + + DxvkMetaClearObjects::DxvkMetaClearObjects(const Rc& vkd) + : m_vkd(vkd) { + + } + + + DxvkMetaClearObjects::~DxvkMetaClearObjects() { + + } + +} diff --git a/src/dxvk/dxvk_meta_clear.h b/src/dxvk/dxvk_meta_clear.h new file mode 100644 index 00000000..76902572 --- /dev/null +++ b/src/dxvk/dxvk_meta_clear.h @@ -0,0 +1,43 @@ +#pragma once + +#include "dxvk_barrier.h" +#include "dxvk_cmdlist.h" +#include "dxvk_resource.h" + +namespace dxvk { + + /** + * \brief Clear args + * + * The data structure that can be passed + * to the clear shaders as push constants. + */ + struct DxvkMetaClearArgs { + VkClearColorValue clearValue; + + alignas(16) VkOffset3D offset; + alignas(16) VkExtent3D extent; + }; + + + /** + * \brief Clear shaders and related objects + * + * Creates the shaders, pipeline layouts, and + * compute pipelines that are going to be used + * for clear operations. + */ + class DxvkMetaClearObjects : public RcObject { + + public: + + DxvkMetaClearObjects(const Rc& vkd); + ~DxvkMetaClearObjects(); + + private: + + Rc m_vkd; + + }; + +} diff --git a/src/dxvk/meson.build b/src/dxvk/meson.build index db7305c4..05d2027e 100644 --- a/src/dxvk/meson.build +++ b/src/dxvk/meson.build @@ -35,6 +35,7 @@ dxvk_src = files([ 'dxvk_lifetime.cpp', 'dxvk_main.cpp', 'dxvk_memory.cpp', + 'dxvk_meta_clear.cpp', 'dxvk_meta_resolve.cpp', 'dxvk_pipecache.cpp', 'dxvk_pipelayout.cpp',