1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[dxvk] Remove asynchronous pipeline compiler

This commit is contained in:
Philip Rebohle 2018-09-13 21:39:56 +02:00
parent d4947261c6
commit 18927dc958
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
9 changed files with 14 additions and 90 deletions

View File

@ -397,7 +397,7 @@ namespace dxvk {
const Rc<DxvkImageView>& imageView, const Rc<DxvkImageView>& imageView,
VkImageAspectFlags clearAspects, VkImageAspectFlags clearAspects,
const VkClearValue& clearValue) { const VkClearValue& clearValue) {
this->updateFramebuffer(false); this->updateFramebuffer();
// Prepare attachment ops // Prepare attachment ops
DxvkColorAttachmentOps colorOp; DxvkColorAttachmentOps colorOp;
@ -1639,7 +1639,7 @@ namespace dxvk {
VkOffset3D offset, VkOffset3D offset,
VkExtent3D extent, VkExtent3D extent,
VkClearValue value) { VkClearValue value) {
this->updateFramebuffer(false); this->updateFramebuffer();
// Find out if the render target view is currently bound, // Find out if the render target view is currently bound,
// so that we can avoid spilling the render pass if it is. // so that we can avoid spilling the render pass if it is.
@ -1974,8 +1974,7 @@ namespace dxvk {
m_gpActivePipeline = m_state.gp.pipeline != nullptr && m_state.om.framebuffer != nullptr m_gpActivePipeline = m_state.gp.pipeline != nullptr && m_state.om.framebuffer != nullptr
? m_state.gp.pipeline->getPipelineHandle(m_state.gp.state, ? m_state.gp.pipeline->getPipelineHandle(m_state.gp.state,
m_state.om.framebuffer->getRenderPass(), m_cmd->statCounters(), m_state.om.framebuffer->getRenderPass(), m_cmd->statCounters())
this->checkAsyncCompilationCompat())
: VK_NULL_HANDLE; : VK_NULL_HANDLE;
if (m_gpActivePipeline != VK_NULL_HANDLE) { if (m_gpActivePipeline != VK_NULL_HANDLE) {
@ -2234,7 +2233,7 @@ namespace dxvk {
} }
void DxvkContext::updateFramebuffer(bool isDraw) { void DxvkContext::updateFramebuffer() {
if (m_flags.test(DxvkContextFlag::GpDirtyFramebuffer)) { if (m_flags.test(DxvkContextFlag::GpDirtyFramebuffer)) {
m_flags.clr(DxvkContextFlag::GpDirtyFramebuffer); m_flags.clr(DxvkContextFlag::GpDirtyFramebuffer);
@ -2253,11 +2252,6 @@ namespace dxvk {
: VkComponentMapping(); : VkComponentMapping();
} }
if (isDraw) {
for (uint32_t i = 0; i < fb->numAttachments(); i++)
fb->getAttachment(i).view->setRtBindingFrameId(m_device->getCurrentFrameId());
}
m_flags.set(DxvkContextFlag::GpDirtyPipelineState); m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
} }
} }
@ -2399,7 +2393,7 @@ namespace dxvk {
void DxvkContext::commitGraphicsState() { void DxvkContext::commitGraphicsState() {
this->updateFramebuffer(true); this->updateFramebuffer();
this->startRenderPass(); this->startRenderPass();
this->updateGraphicsPipeline(); this->updateGraphicsPipeline();
this->updateIndexBufferBinding(); this->updateIndexBufferBinding();
@ -2525,17 +2519,5 @@ namespace dxvk {
} }
} }
} }
bool DxvkContext::checkAsyncCompilationCompat() {
bool fbCompat = m_device->config().asyncPipeCompiler;
for (uint32_t i = 0; fbCompat && i < m_state.om.framebuffer->numAttachments(); i++) {
const auto& attachment = m_state.om.framebuffer->getAttachment(i);
fbCompat &= attachment.view->getRtBindingAsyncCompilationCompat();
}
return fbCompat;
}
} }

View File

@ -713,7 +713,7 @@ namespace dxvk {
VkDescriptorSet set, VkDescriptorSet set,
const DxvkPipelineLayout* layout); const DxvkPipelineLayout* layout);
void updateFramebuffer(bool isDraw); void updateFramebuffer();
void updateIndexBufferBinding(); void updateIndexBufferBinding();
void updateVertexBufferBindings(); void updateVertexBufferBindings();
@ -729,8 +729,6 @@ namespace dxvk {
void commitComputeInitBarriers(); void commitComputeInitBarriers();
void commitComputePostBarriers(); void commitComputePostBarriers();
bool checkAsyncCompilationCompat();
Rc<DxvkBuffer> getTransferBuffer(VkDeviceSize size); Rc<DxvkBuffer> getTransferBuffer(VkDeviceSize size);
}; };

View File

@ -56,14 +56,12 @@ namespace dxvk {
DxvkGraphicsPipeline::DxvkGraphicsPipeline( DxvkGraphicsPipeline::DxvkGraphicsPipeline(
const DxvkDevice* device, const DxvkDevice* device,
const Rc<DxvkPipelineCache>& cache, const Rc<DxvkPipelineCache>& cache,
const Rc<DxvkPipelineCompiler>& compiler,
const Rc<DxvkShader>& vs, const Rc<DxvkShader>& vs,
const Rc<DxvkShader>& tcs, const Rc<DxvkShader>& tcs,
const Rc<DxvkShader>& tes, const Rc<DxvkShader>& tes,
const Rc<DxvkShader>& gs, const Rc<DxvkShader>& gs,
const Rc<DxvkShader>& fs) const Rc<DxvkShader>& fs)
: m_device(device), m_vkd(device->vkd()), : m_device(device), m_vkd(device->vkd()), m_cache(cache) {
m_cache(cache), m_compiler(compiler) {
DxvkDescriptorSlotMapping slotMapping; DxvkDescriptorSlotMapping slotMapping;
if (vs != nullptr) vs ->defineResourceSlots(slotMapping); if (vs != nullptr) vs ->defineResourceSlots(slotMapping);
if (tcs != nullptr) tcs->defineResourceSlots(slotMapping); if (tcs != nullptr) tcs->defineResourceSlots(slotMapping);
@ -102,8 +100,7 @@ namespace dxvk {
VkPipeline DxvkGraphicsPipeline::getPipelineHandle( VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state, const DxvkGraphicsPipelineStateInfo& state,
const DxvkRenderPass& renderPass, const DxvkRenderPass& renderPass,
DxvkStatCounters& stats, DxvkStatCounters& stats) {
bool async) {
VkRenderPass renderPassHandle = renderPass.getDefaultHandle(); VkRenderPass renderPassHandle = renderPass.getDefaultHandle();
{ std::lock_guard<sync::Spinlock> lock(m_mutex); { std::lock_guard<sync::Spinlock> lock(m_mutex);
@ -123,12 +120,8 @@ namespace dxvk {
// If no pipeline instance exists with the given state // If no pipeline instance exists with the given state
// vector, create a new one and add it to the list. // vector, create a new one and add it to the list.
VkPipeline newPipelineBase = m_basePipeline.load(); VkPipeline newPipelineBase = m_basePipeline.load();
VkPipeline newPipelineHandle = VK_NULL_HANDLE; VkPipeline newPipelineHandle = this->compilePipeline(
state, renderPassHandle, newPipelineBase);
if (!async) {
newPipelineHandle = this->compilePipeline(
state, renderPassHandle, newPipelineBase);
}
Rc<DxvkGraphicsPipelineInstance> newPipeline = Rc<DxvkGraphicsPipelineInstance> newPipeline =
new DxvkGraphicsPipelineInstance(m_device->vkd(), new DxvkGraphicsPipelineInstance(m_device->vkd(),
@ -154,10 +147,6 @@ namespace dxvk {
if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE) if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE)
m_basePipeline.compare_exchange_strong(newPipelineBase, newPipelineHandle); m_basePipeline.compare_exchange_strong(newPipelineBase, newPipelineHandle);
// Compile pipeline asynchronously if requested
if (async)
m_compiler->queueCompilation(this, newPipeline);
return newPipelineHandle; return newPipelineHandle;
} }

View File

@ -167,7 +167,6 @@ namespace dxvk {
DxvkGraphicsPipeline( DxvkGraphicsPipeline(
const DxvkDevice* device, const DxvkDevice* device,
const Rc<DxvkPipelineCache>& cache, const Rc<DxvkPipelineCache>& cache,
const Rc<DxvkPipelineCompiler>& compiler,
const Rc<DxvkShader>& vs, const Rc<DxvkShader>& vs,
const Rc<DxvkShader>& tcs, const Rc<DxvkShader>& tcs,
const Rc<DxvkShader>& tes, const Rc<DxvkShader>& tes,
@ -195,14 +194,12 @@ namespace dxvk {
* \param [in] state Pipeline state vector * \param [in] state Pipeline state vector
* \param [in] renderPass The render pass * \param [in] renderPass The render pass
* \param [in,out] stats Stat counter * \param [in,out] stats Stat counter
* \param [in] async Compile asynchronously
* \returns Pipeline handle * \returns Pipeline handle
*/ */
VkPipeline getPipelineHandle( VkPipeline getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state, const DxvkGraphicsPipelineStateInfo& state,
const DxvkRenderPass& renderPass, const DxvkRenderPass& renderPass,
DxvkStatCounters& stats, DxvkStatCounters& stats);
bool async);
/** /**
* \brief Compiles optimized pipeline * \brief Compiles optimized pipeline
@ -226,7 +223,6 @@ namespace dxvk {
const Rc<vk::DeviceFn> m_vkd; const Rc<vk::DeviceFn> m_vkd;
Rc<DxvkPipelineCache> m_cache; Rc<DxvkPipelineCache> m_cache;
Rc<DxvkPipelineCompiler> m_compiler;
Rc<DxvkPipelineLayout> m_layout; Rc<DxvkPipelineLayout> m_layout;
Rc<DxvkShaderModule> m_vs; Rc<DxvkShaderModule> m_vs;

View File

@ -377,37 +377,6 @@ namespace dxvk {
return m_image->pickLayout(layout); return m_image->pickLayout(layout);
} }
/**
* \brief Sets render target usage frame number
*
* The image view will track internally when
* it was last used as a render target. This
* info is used for async shader compilation.
* \param [in] frameId Frame number
*/
void setRtBindingFrameId(uint32_t frameId) {
if (frameId != m_rtBindingFrameId) {
if (frameId == m_rtBindingFrameId + 1)
m_rtBindingFrameCount += 1;
else
m_rtBindingFrameCount = 0;
m_rtBindingFrameId = frameId;
}
}
/**
* \brief Checks for async pipeline compatibility
*
* Asynchronous pipeline compilation may be enabled if the
* render target has been drawn to in the previous frames.
* \param [in] frameId Current frame ID
* \returns \c true if async compilation is supported
*/
bool getRtBindingAsyncCompilationCompat() const {
return m_rtBindingFrameCount >= 5;
}
private: private:
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;
@ -416,9 +385,6 @@ namespace dxvk {
DxvkImageViewCreateInfo m_info; DxvkImageViewCreateInfo m_info;
VkImageView m_views[ViewCount]; VkImageView m_views[ViewCount];
uint32_t m_rtBindingFrameId = 0;
uint32_t m_rtBindingFrameCount = 0;
void createView(VkImageViewType type, uint32_t numLayers); void createView(VkImageViewType type, uint32_t numLayers);
}; };

View File

@ -4,7 +4,6 @@ namespace dxvk {
DxvkOptions::DxvkOptions(const Config& config) { DxvkOptions::DxvkOptions(const Config& config) {
allowMemoryOvercommit = config.getOption<bool>("dxvk.allowMemoryOvercommit", false); allowMemoryOvercommit = config.getOption<bool>("dxvk.allowMemoryOvercommit", false);
asyncPipeCompiler = false; // config.getOption<bool>("dxvk.asyncPipeCompiler", false);
} }
} }

View File

@ -10,9 +10,6 @@ namespace dxvk {
/// Allow allocating more memory from /// Allow allocating more memory from
/// a heap than the device supports. /// a heap than the device supports.
bool allowMemoryOvercommit; bool allowMemoryOvercommit;
/// Enable asynchronous pipeline compilation.
bool asyncPipeCompiler;
}; };
} }

View File

@ -40,10 +40,8 @@ namespace dxvk {
DxvkPipelineManager::DxvkPipelineManager(const DxvkDevice* device) DxvkPipelineManager::DxvkPipelineManager(const DxvkDevice* device)
: m_device (device), : m_device (device),
m_cache (new DxvkPipelineCache(device->vkd())), m_cache (new DxvkPipelineCache(device->vkd())) {
m_compiler(nullptr) {
if (m_device->config().asyncPipeCompiler)
m_compiler = new DxvkPipelineCompiler();
} }
@ -97,7 +95,7 @@ namespace dxvk {
return pair->second; return pair->second;
Rc<DxvkGraphicsPipeline> pipeline = new DxvkGraphicsPipeline( Rc<DxvkGraphicsPipeline> pipeline = new DxvkGraphicsPipeline(
m_device, m_cache, m_compiler, vs, tcs, tes, gs, fs); m_device, m_cache, vs, tcs, tes, gs, fs);
m_graphicsPipelines.insert(std::make_pair(key, pipeline)); m_graphicsPipelines.insert(std::make_pair(key, pipeline));
return pipeline; return pipeline;

View File

@ -99,7 +99,6 @@ namespace dxvk {
const DxvkDevice* m_device; const DxvkDevice* m_device;
Rc<DxvkPipelineCache> m_cache; Rc<DxvkPipelineCache> m_cache;
Rc<DxvkPipelineCompiler> m_compiler;
std::mutex m_mutex; std::mutex m_mutex;