2018-02-14 17:54:35 +01:00
|
|
|
#include <cstring>
|
|
|
|
|
2017-10-13 03:19:23 +02:00
|
|
|
#include "dxvk_compute.h"
|
2018-01-16 15:00:19 +01:00
|
|
|
#include "dxvk_device.h"
|
2017-10-13 03:19:23 +02:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-02-14 17:54:35 +01:00
|
|
|
bool DxvkComputePipelineStateInfo::operator == (const DxvkComputePipelineStateInfo& other) const {
|
|
|
|
return std::memcmp(this, &other, sizeof(DxvkComputePipelineStateInfo)) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DxvkComputePipelineStateInfo::operator != (const DxvkComputePipelineStateInfo& other) const {
|
|
|
|
return std::memcmp(this, &other, sizeof(DxvkComputePipelineStateInfo)) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-13 03:19:23 +02:00
|
|
|
DxvkComputePipeline::DxvkComputePipeline(
|
2018-01-16 15:00:19 +01:00
|
|
|
const DxvkDevice* device,
|
2018-01-13 22:18:32 +01:00
|
|
|
const Rc<DxvkPipelineCache>& cache,
|
|
|
|
const Rc<DxvkShader>& cs)
|
2018-01-16 15:00:19 +01:00
|
|
|
: m_device(device), m_vkd(device->vkd()),
|
|
|
|
m_cache(cache) {
|
2017-12-07 09:38:31 +01:00
|
|
|
DxvkDescriptorSlotMapping slotMapping;
|
|
|
|
cs->defineResourceSlots(slotMapping);
|
|
|
|
|
2018-01-23 17:40:36 +01:00
|
|
|
m_layout = new DxvkPipelineLayout(m_vkd,
|
2017-12-07 09:38:31 +01:00
|
|
|
slotMapping.bindingCount(),
|
|
|
|
slotMapping.bindingInfos());
|
|
|
|
|
2018-01-16 15:00:19 +01:00
|
|
|
m_cs = cs->createShaderModule(m_vkd, slotMapping);
|
2017-12-07 09:38:31 +01:00
|
|
|
|
|
|
|
this->compilePipeline();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxvkComputePipeline::~DxvkComputePipeline() {
|
|
|
|
if (m_pipeline != VK_NULL_HANDLE)
|
|
|
|
m_vkd->vkDestroyPipeline(m_vkd->device(), m_pipeline, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-14 17:54:35 +01:00
|
|
|
VkPipeline DxvkComputePipeline::getPipelineHandle(
|
|
|
|
const DxvkComputePipelineStateInfo& state) const {
|
|
|
|
// TODO take pipeine state into account
|
|
|
|
return m_pipeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-07 09:38:31 +01:00
|
|
|
void DxvkComputePipeline::compilePipeline() {
|
2017-10-14 23:52:47 +02:00
|
|
|
std::vector<VkDescriptorSetLayoutBinding> bindings;
|
2018-03-02 02:33:06 -07:00
|
|
|
|
|
|
|
if (Logger::logLevel() <= LogLevel::Debug) {
|
|
|
|
Logger::debug("Compiling compute pipeline...");
|
|
|
|
Logger::debug(str::format(" cs : ", m_cs ->debugName()));
|
|
|
|
}
|
2017-10-14 23:52:47 +02:00
|
|
|
|
|
|
|
VkComputePipelineCreateInfo info;
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
|
|
|
|
info.pNext = nullptr;
|
|
|
|
info.flags = 0;
|
2018-01-10 11:44:40 +01:00
|
|
|
info.stage = m_cs->stageInfo(nullptr);
|
2017-12-03 20:23:26 +01:00
|
|
|
info.layout = m_layout->pipelineLayout();
|
2017-10-14 23:52:47 +02:00
|
|
|
info.basePipelineHandle = VK_NULL_HANDLE;
|
2018-01-10 22:54:00 +01:00
|
|
|
info.basePipelineIndex = -1;
|
2017-10-14 23:52:47 +02:00
|
|
|
|
|
|
|
if (m_vkd->vkCreateComputePipelines(m_vkd->device(),
|
2018-01-13 22:18:32 +01:00
|
|
|
m_cache->handle(), 1, &info, nullptr, &m_pipeline) != VK_SUCCESS)
|
2018-01-31 00:48:39 +01:00
|
|
|
Logger::err("DxvkComputePipeline: Failed to compile pipeline");
|
2017-10-13 03:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|