2017-10-15 13:02:59 +02:00
|
|
|
#include "dxvk_graphics.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2017-11-20 13:21:27 +01:00
|
|
|
template<typename T>
|
|
|
|
size_t hashPtr(T* ptr) {
|
|
|
|
return reinterpret_cast<size_t>(ptr);
|
|
|
|
}
|
|
|
|
|
2017-10-15 17:56:06 +02:00
|
|
|
size_t DxvkGraphicsPipelineStateInfo::hash() const {
|
2017-11-20 13:21:27 +01:00
|
|
|
DxvkHashState state;
|
|
|
|
state.add(hashPtr(this->inputAssembly.ptr()));
|
|
|
|
state.add(hashPtr(this->inputLayout.ptr()));
|
|
|
|
state.add(hashPtr(this->rasterizerState.ptr()));
|
|
|
|
state.add(hashPtr(this->multisampleState.ptr()));
|
|
|
|
state.add(hashPtr(this->depthStencilState.ptr()));
|
|
|
|
state.add(hashPtr(this->blendState.ptr()));
|
|
|
|
state.add(std::hash<VkRenderPass>()(this->renderPass));
|
|
|
|
state.add(viewportCount);
|
|
|
|
return state;
|
2017-10-15 13:02:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-15 17:56:06 +02:00
|
|
|
bool DxvkGraphicsPipelineStateInfo::operator == (const DxvkGraphicsPipelineStateInfo& other) const {
|
2017-11-20 13:21:27 +01:00
|
|
|
return this->inputAssembly == other.inputAssembly
|
|
|
|
&& this->inputLayout == other.inputLayout
|
|
|
|
&& this->rasterizerState == other.rasterizerState
|
|
|
|
&& this->multisampleState == other.multisampleState
|
|
|
|
&& this->depthStencilState == other.depthStencilState
|
|
|
|
&& this->blendState == other.blendState
|
|
|
|
&& this->renderPass == other.renderPass
|
|
|
|
&& this->viewportCount == other.viewportCount;
|
2017-10-15 13:02:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-15 17:56:06 +02:00
|
|
|
bool DxvkGraphicsPipelineStateInfo::operator != (const DxvkGraphicsPipelineStateInfo& other) const {
|
2017-10-15 13:02:59 +02:00
|
|
|
return !this->operator == (other);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxvkGraphicsPipeline::DxvkGraphicsPipeline(
|
|
|
|
const Rc<vk::DeviceFn>& vkd,
|
|
|
|
const Rc<DxvkShader>& vs,
|
|
|
|
const Rc<DxvkShader>& tcs,
|
|
|
|
const Rc<DxvkShader>& tes,
|
|
|
|
const Rc<DxvkShader>& gs,
|
|
|
|
const Rc<DxvkShader>& fs)
|
|
|
|
: m_vkd(vkd), m_vs(vs), m_tcs(tcs),
|
|
|
|
m_tes(tes), m_gs(gs), m_fs(fs) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxvkGraphicsPipeline::~DxvkGraphicsPipeline() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
|
2017-10-15 17:56:06 +02:00
|
|
|
const DxvkGraphicsPipelineStateInfo& state) {
|
2017-10-15 13:02:59 +02:00
|
|
|
std::lock_guard<std::mutex> lock(m_mutex);
|
|
|
|
|
|
|
|
auto pair = m_pipelines.find(state);
|
|
|
|
if (pair != m_pipelines.end())
|
|
|
|
return pair->second;
|
|
|
|
|
|
|
|
VkPipeline pipeline = this->compilePipeline(state);
|
|
|
|
m_pipelines.insert(std::make_pair(state, pipeline));
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VkPipeline DxvkGraphicsPipeline::compilePipeline(
|
2017-10-15 17:56:06 +02:00
|
|
|
const DxvkGraphicsPipelineStateInfo& state) const {
|
2017-10-15 13:02:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|