mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[dxvk] Remove shader-based resolve
No longer necessary since we're using render pass resolve now.
This commit is contained in:
parent
75ee1f42c2
commit
73bb0d8ae2
@ -14,8 +14,7 @@ namespace dxvk {
|
|||||||
const Rc<DxvkMetaClearObjects>& metaClearObjects,
|
const Rc<DxvkMetaClearObjects>& metaClearObjects,
|
||||||
const Rc<DxvkMetaCopyObjects>& metaCopyObjects,
|
const Rc<DxvkMetaCopyObjects>& metaCopyObjects,
|
||||||
const Rc<DxvkMetaMipGenObjects>& metaMipGenObjects,
|
const Rc<DxvkMetaMipGenObjects>& metaMipGenObjects,
|
||||||
const Rc<DxvkMetaPackObjects>& metaPackObjects,
|
const Rc<DxvkMetaPackObjects>& metaPackObjects)
|
||||||
const Rc<DxvkMetaResolveObjects>& metaResolveObjects)
|
|
||||||
: m_device (device),
|
: m_device (device),
|
||||||
m_pipeMgr (pipelineManager),
|
m_pipeMgr (pipelineManager),
|
||||||
m_gpuEvents (gpuEventPool),
|
m_gpuEvents (gpuEventPool),
|
||||||
@ -23,7 +22,6 @@ namespace dxvk {
|
|||||||
m_metaCopy (metaCopyObjects),
|
m_metaCopy (metaCopyObjects),
|
||||||
m_metaMipGen (metaMipGenObjects),
|
m_metaMipGen (metaMipGenObjects),
|
||||||
m_metaPack (metaPackObjects),
|
m_metaPack (metaPackObjects),
|
||||||
m_metaResolve (metaResolveObjects),
|
|
||||||
m_queryManager(gpuQueryPool) {
|
m_queryManager(gpuQueryPool) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@ namespace dxvk {
|
|||||||
const Rc<DxvkMetaClearObjects>& metaClearObjects,
|
const Rc<DxvkMetaClearObjects>& metaClearObjects,
|
||||||
const Rc<DxvkMetaCopyObjects>& metaCopyObjects,
|
const Rc<DxvkMetaCopyObjects>& metaCopyObjects,
|
||||||
const Rc<DxvkMetaMipGenObjects>& metaMipGenObjects,
|
const Rc<DxvkMetaMipGenObjects>& metaMipGenObjects,
|
||||||
const Rc<DxvkMetaPackObjects>& metaPackObjects,
|
const Rc<DxvkMetaPackObjects>& metaPackObjects);
|
||||||
const Rc<DxvkMetaResolveObjects>& metaResolveObjects);
|
|
||||||
~DxvkContext();
|
~DxvkContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -795,7 +794,6 @@ namespace dxvk {
|
|||||||
const Rc<DxvkMetaCopyObjects> m_metaCopy;
|
const Rc<DxvkMetaCopyObjects> m_metaCopy;
|
||||||
const Rc<DxvkMetaMipGenObjects> m_metaMipGen;
|
const Rc<DxvkMetaMipGenObjects> m_metaMipGen;
|
||||||
const Rc<DxvkMetaPackObjects> m_metaPack;
|
const Rc<DxvkMetaPackObjects> m_metaPack;
|
||||||
const Rc<DxvkMetaResolveObjects> m_metaResolve;
|
|
||||||
|
|
||||||
Rc<DxvkCommandList> m_cmd;
|
Rc<DxvkCommandList> m_cmd;
|
||||||
Rc<DxvkDescriptorPool> m_descPool;
|
Rc<DxvkDescriptorPool> m_descPool;
|
||||||
|
@ -25,7 +25,6 @@ namespace dxvk {
|
|||||||
m_metaCopyObjects (new DxvkMetaCopyObjects (vkd)),
|
m_metaCopyObjects (new DxvkMetaCopyObjects (vkd)),
|
||||||
m_metaMipGenObjects (new DxvkMetaMipGenObjects (vkd)),
|
m_metaMipGenObjects (new DxvkMetaMipGenObjects (vkd)),
|
||||||
m_metaPackObjects (new DxvkMetaPackObjects (vkd)),
|
m_metaPackObjects (new DxvkMetaPackObjects (vkd)),
|
||||||
m_metaResolveObjects(new DxvkMetaResolveObjects (vkd)),
|
|
||||||
m_unboundResources (this),
|
m_unboundResources (this),
|
||||||
m_submissionQueue (this) {
|
m_submissionQueue (this) {
|
||||||
m_graphicsQueue.queueFamily = m_adapter->graphicsQueueFamily();
|
m_graphicsQueue.queueFamily = m_adapter->graphicsQueueFamily();
|
||||||
@ -147,8 +146,7 @@ namespace dxvk {
|
|||||||
m_metaClearObjects,
|
m_metaClearObjects,
|
||||||
m_metaCopyObjects,
|
m_metaCopyObjects,
|
||||||
m_metaMipGenObjects,
|
m_metaMipGenObjects,
|
||||||
m_metaPackObjects,
|
m_metaPackObjects);
|
||||||
m_metaResolveObjects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -423,7 +423,6 @@ namespace dxvk {
|
|||||||
Rc<DxvkMetaCopyObjects> m_metaCopyObjects;
|
Rc<DxvkMetaCopyObjects> m_metaCopyObjects;
|
||||||
Rc<DxvkMetaMipGenObjects> m_metaMipGenObjects;
|
Rc<DxvkMetaMipGenObjects> m_metaMipGenObjects;
|
||||||
Rc<DxvkMetaPackObjects> m_metaPackObjects;
|
Rc<DxvkMetaPackObjects> m_metaPackObjects;
|
||||||
Rc<DxvkMetaResolveObjects> m_metaResolveObjects;
|
|
||||||
|
|
||||||
DxvkUnboundResources m_unboundResources;
|
DxvkUnboundResources m_unboundResources;
|
||||||
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
#include "dxvk_meta_resolve.h"
|
#include "dxvk_meta_resolve.h"
|
||||||
|
|
||||||
#include <dxvk_resolve_vert.h>
|
|
||||||
#include <dxvk_resolve_geom.h>
|
|
||||||
#include <dxvk_resolve_frag_f.h>
|
|
||||||
#include <dxvk_resolve_frag_i.h>
|
|
||||||
#include <dxvk_resolve_frag_u.h>
|
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
DxvkMetaResolveRenderPass::DxvkMetaResolveRenderPass(
|
DxvkMetaResolveRenderPass::DxvkMetaResolveRenderPass(
|
||||||
@ -111,342 +105,4 @@ namespace dxvk {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaResolveObjects::DxvkMetaResolveObjects(const Rc<vk::DeviceFn>& vkd)
|
|
||||||
: m_vkd (vkd),
|
|
||||||
m_sampler (createSampler()),
|
|
||||||
m_shaderVert (createShaderModule(dxvk_resolve_vert)),
|
|
||||||
m_shaderGeom (createShaderModule(dxvk_resolve_geom)),
|
|
||||||
m_shaderFragF (createShaderModule(dxvk_resolve_frag_f)),
|
|
||||||
m_shaderFragI (createShaderModule(dxvk_resolve_frag_i)),
|
|
||||||
m_shaderFragU (createShaderModule(dxvk_resolve_frag_u)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaResolveObjects::~DxvkMetaResolveObjects() {
|
|
||||||
for (const auto& pair : m_pipelines) {
|
|
||||||
m_vkd->vkDestroyPipeline(m_vkd->device(), pair.second.pipeHandle, nullptr);
|
|
||||||
m_vkd->vkDestroyPipelineLayout(m_vkd->device(), pair.second.pipeLayout, nullptr);
|
|
||||||
m_vkd->vkDestroyDescriptorSetLayout (m_vkd->device(), pair.second.dsetLayout, nullptr);
|
|
||||||
m_vkd->vkDestroyRenderPass(m_vkd->device(), pair.second.renderPass, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderFragI, nullptr);
|
|
||||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderFragU, nullptr);
|
|
||||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderFragF, nullptr);
|
|
||||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderGeom, nullptr);
|
|
||||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderVert, nullptr);
|
|
||||||
|
|
||||||
m_vkd->vkDestroySampler(m_vkd->device(), m_sampler, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaResolvePipeline DxvkMetaResolveObjects::getPipeline(VkFormat format) {
|
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
|
||||||
|
|
||||||
auto entry = m_pipelines.find(format);
|
|
||||||
if (entry != m_pipelines.end())
|
|
||||||
return entry->second;
|
|
||||||
|
|
||||||
DxvkMetaResolvePipeline pipeline = this->createPipeline(format);
|
|
||||||
m_pipelines.insert({ format, pipeline });
|
|
||||||
return pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkSampler DxvkMetaResolveObjects::createSampler() const {
|
|
||||||
VkSamplerCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.magFilter = VK_FILTER_NEAREST;
|
|
||||||
info.minFilter = VK_FILTER_NEAREST;
|
|
||||||
info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
|
||||||
info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
|
||||||
info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
|
||||||
info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
|
||||||
info.mipLodBias = 0.0f;
|
|
||||||
info.anisotropyEnable = VK_FALSE;
|
|
||||||
info.maxAnisotropy = 1.0f;
|
|
||||||
info.compareEnable = VK_FALSE;
|
|
||||||
info.compareOp = VK_COMPARE_OP_ALWAYS;
|
|
||||||
info.minLod = 0.0f;
|
|
||||||
info.maxLod = 0.0f;
|
|
||||||
info.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
|
||||||
info.unnormalizedCoordinates = VK_FALSE;
|
|
||||||
|
|
||||||
VkSampler result = VK_NULL_HANDLE;
|
|
||||||
if (m_vkd->vkCreateSampler(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaResolveObjects: Failed to create sampler");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkShaderModule DxvkMetaResolveObjects::createShaderModule(const SpirvCodeBuffer& code) const {
|
|
||||||
VkShaderModuleCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.codeSize = code.size();
|
|
||||||
info.pCode = code.data();
|
|
||||||
|
|
||||||
VkShaderModule result = VK_NULL_HANDLE;
|
|
||||||
if (m_vkd->vkCreateShaderModule(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaResolveObjects: Failed to create shader module");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaResolvePipeline DxvkMetaResolveObjects::createPipeline(VkFormat format) {
|
|
||||||
DxvkMetaResolvePipeline pipeline;
|
|
||||||
pipeline.renderPass = this->createRenderPass(format);
|
|
||||||
pipeline.dsetLayout = this->createDescriptorSetLayout();
|
|
||||||
pipeline.pipeLayout = this->createPipelineLayout(pipeline.dsetLayout);
|
|
||||||
pipeline.pipeHandle = this->createPipeline(pipeline.pipeLayout, pipeline.renderPass, format);
|
|
||||||
return pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkRenderPass DxvkMetaResolveObjects::createRenderPass(VkFormat format) const {
|
|
||||||
VkAttachmentDescription attachment;
|
|
||||||
attachment.flags = 0;
|
|
||||||
attachment.format = format;
|
|
||||||
attachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
|
||||||
attachment.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
|
||||||
attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
|
||||||
attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
|
||||||
attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
|
||||||
attachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
attachment.finalLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
|
|
||||||
VkAttachmentReference attachmentRef;
|
|
||||||
attachmentRef.attachment = 0;
|
|
||||||
attachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
|
||||||
|
|
||||||
VkSubpassDescription subpass;
|
|
||||||
subpass.flags = 0;
|
|
||||||
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
|
||||||
subpass.inputAttachmentCount = 0;
|
|
||||||
subpass.pInputAttachments = nullptr;
|
|
||||||
subpass.colorAttachmentCount = 1;
|
|
||||||
subpass.pColorAttachments = &attachmentRef;
|
|
||||||
subpass.pResolveAttachments = nullptr;
|
|
||||||
subpass.pDepthStencilAttachment = nullptr;
|
|
||||||
subpass.preserveAttachmentCount = 0;
|
|
||||||
subpass.pPreserveAttachments = nullptr;
|
|
||||||
|
|
||||||
VkRenderPassCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.attachmentCount = 1;
|
|
||||||
info.pAttachments = &attachment;
|
|
||||||
info.subpassCount = 1;
|
|
||||||
info.pSubpasses = &subpass;
|
|
||||||
info.dependencyCount = 0;
|
|
||||||
info.pDependencies = nullptr;
|
|
||||||
|
|
||||||
VkRenderPass result = VK_NULL_HANDLE;
|
|
||||||
if (m_vkd->vkCreateRenderPass(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaResolveObjects: Failed to create render pass");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkDescriptorSetLayout DxvkMetaResolveObjects::createDescriptorSetLayout() const {
|
|
||||||
VkDescriptorSetLayoutBinding binding;
|
|
||||||
binding.binding = 0;
|
|
||||||
binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
|
||||||
binding.descriptorCount = 1;
|
|
||||||
binding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
||||||
binding.pImmutableSamplers = &m_sampler;
|
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.bindingCount = 1;
|
|
||||||
info.pBindings = &binding;
|
|
||||||
|
|
||||||
VkDescriptorSetLayout result = VK_NULL_HANDLE;
|
|
||||||
if (m_vkd->vkCreateDescriptorSetLayout(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaMipGenObjects: Failed to create descriptor set layout");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkPipelineLayout DxvkMetaResolveObjects::createPipelineLayout(
|
|
||||||
VkDescriptorSetLayout descriptorSetLayout) const {
|
|
||||||
VkPipelineLayoutCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.setLayoutCount = 1;
|
|
||||||
info.pSetLayouts = &descriptorSetLayout;
|
|
||||||
info.pushConstantRangeCount = 0;
|
|
||||||
info.pPushConstantRanges = nullptr;
|
|
||||||
|
|
||||||
VkPipelineLayout result = VK_NULL_HANDLE;
|
|
||||||
if (m_vkd->vkCreatePipelineLayout(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaMipGenObjects: Failed to create pipeline layout");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkPipeline DxvkMetaResolveObjects::createPipeline(
|
|
||||||
VkPipelineLayout pipelineLayout,
|
|
||||||
VkRenderPass renderPass,
|
|
||||||
VkFormat format) const {
|
|
||||||
std::array<VkPipelineShaderStageCreateInfo, 3> stages;
|
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo& vsStage = stages[0];
|
|
||||||
vsStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
|
||||||
vsStage.pNext = nullptr;
|
|
||||||
vsStage.flags = 0;
|
|
||||||
vsStage.stage = VK_SHADER_STAGE_VERTEX_BIT;
|
|
||||||
vsStage.module = m_shaderVert;
|
|
||||||
vsStage.pName = "main";
|
|
||||||
vsStage.pSpecializationInfo = nullptr;
|
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo& gsStage = stages[1];
|
|
||||||
gsStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
|
||||||
gsStage.pNext = nullptr;
|
|
||||||
gsStage.flags = 0;
|
|
||||||
gsStage.stage = VK_SHADER_STAGE_GEOMETRY_BIT;
|
|
||||||
gsStage.module = m_shaderGeom;
|
|
||||||
gsStage.pName = "main";
|
|
||||||
gsStage.pSpecializationInfo = nullptr;
|
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo& psStage = stages[2];
|
|
||||||
psStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
|
||||||
psStage.pNext = nullptr;
|
|
||||||
psStage.flags = 0;
|
|
||||||
psStage.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
||||||
psStage.module = m_shaderFragF;
|
|
||||||
psStage.pName = "main";
|
|
||||||
psStage.pSpecializationInfo = nullptr;
|
|
||||||
|
|
||||||
auto formatInfo = imageFormatInfo(format);
|
|
||||||
|
|
||||||
if (formatInfo->flags.test(DxvkFormatFlag::SampledUInt))
|
|
||||||
psStage.module = m_shaderFragU;
|
|
||||||
if (formatInfo->flags.test(DxvkFormatFlag::SampledSInt))
|
|
||||||
psStage.module = m_shaderFragI;
|
|
||||||
|
|
||||||
std::array<VkDynamicState, 2> dynStates = {{
|
|
||||||
VK_DYNAMIC_STATE_VIEWPORT,
|
|
||||||
VK_DYNAMIC_STATE_SCISSOR,
|
|
||||||
}};
|
|
||||||
|
|
||||||
VkPipelineDynamicStateCreateInfo dynState;
|
|
||||||
dynState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
|
||||||
dynState.pNext = nullptr;
|
|
||||||
dynState.flags = 0;
|
|
||||||
dynState.dynamicStateCount = dynStates.size();
|
|
||||||
dynState.pDynamicStates = dynStates.data();
|
|
||||||
|
|
||||||
VkPipelineVertexInputStateCreateInfo viState;
|
|
||||||
viState.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
|
||||||
viState.pNext = nullptr;
|
|
||||||
viState.flags = 0;
|
|
||||||
viState.vertexBindingDescriptionCount = 0;
|
|
||||||
viState.pVertexBindingDescriptions = nullptr;
|
|
||||||
viState.vertexAttributeDescriptionCount = 0;
|
|
||||||
viState.pVertexAttributeDescriptions = nullptr;
|
|
||||||
|
|
||||||
VkPipelineInputAssemblyStateCreateInfo iaState;
|
|
||||||
iaState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
|
||||||
iaState.pNext = nullptr;
|
|
||||||
iaState.flags = 0;
|
|
||||||
iaState.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
|
|
||||||
iaState.primitiveRestartEnable = VK_FALSE;
|
|
||||||
|
|
||||||
VkPipelineViewportStateCreateInfo vpState;
|
|
||||||
vpState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
|
||||||
vpState.pNext = nullptr;
|
|
||||||
vpState.flags = 0;
|
|
||||||
vpState.viewportCount = 1;
|
|
||||||
vpState.pViewports = nullptr;
|
|
||||||
vpState.scissorCount = 1;
|
|
||||||
vpState.pScissors = nullptr;
|
|
||||||
|
|
||||||
VkPipelineRasterizationStateCreateInfo rsState;
|
|
||||||
rsState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
|
||||||
rsState.pNext = nullptr;
|
|
||||||
rsState.flags = 0;
|
|
||||||
rsState.depthClampEnable = VK_TRUE;
|
|
||||||
rsState.rasterizerDiscardEnable = VK_FALSE;
|
|
||||||
rsState.polygonMode = VK_POLYGON_MODE_FILL;
|
|
||||||
rsState.cullMode = VK_CULL_MODE_NONE;
|
|
||||||
rsState.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
|
||||||
rsState.depthBiasEnable = VK_FALSE;
|
|
||||||
rsState.depthBiasConstantFactor = 0.0f;
|
|
||||||
rsState.depthBiasClamp = 0.0f;
|
|
||||||
rsState.depthBiasSlopeFactor = 0.0f;
|
|
||||||
rsState.lineWidth = 1.0f;
|
|
||||||
|
|
||||||
uint32_t msMask = 0xFFFFFFFF;
|
|
||||||
VkPipelineMultisampleStateCreateInfo msState;
|
|
||||||
msState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
|
||||||
msState.pNext = nullptr;
|
|
||||||
msState.flags = 0;
|
|
||||||
msState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
|
||||||
msState.sampleShadingEnable = VK_FALSE;
|
|
||||||
msState.minSampleShading = 1.0f;
|
|
||||||
msState.pSampleMask = &msMask;
|
|
||||||
msState.alphaToCoverageEnable = VK_FALSE;
|
|
||||||
msState.alphaToOneEnable = VK_FALSE;
|
|
||||||
|
|
||||||
VkPipelineColorBlendAttachmentState cbAttachment;
|
|
||||||
cbAttachment.blendEnable = VK_FALSE;
|
|
||||||
cbAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
|
|
||||||
cbAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
|
|
||||||
cbAttachment.colorBlendOp = VK_BLEND_OP_ADD;
|
|
||||||
cbAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
|
|
||||||
cbAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
|
||||||
cbAttachment.alphaBlendOp = VK_BLEND_OP_ADD;
|
|
||||||
cbAttachment.colorWriteMask =
|
|
||||||
VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
|
||||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
|
||||||
|
|
||||||
VkPipelineColorBlendStateCreateInfo cbState;
|
|
||||||
cbState.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
|
||||||
cbState.pNext = nullptr;
|
|
||||||
cbState.flags = 0;
|
|
||||||
cbState.logicOpEnable = VK_FALSE;
|
|
||||||
cbState.logicOp = VK_LOGIC_OP_NO_OP;
|
|
||||||
cbState.attachmentCount = 1;
|
|
||||||
cbState.pAttachments = &cbAttachment;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 4; i++)
|
|
||||||
cbState.blendConstants[i] = 0.0f;
|
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.stageCount = stages.size();
|
|
||||||
info.pStages = stages.data();
|
|
||||||
info.pVertexInputState = &viState;
|
|
||||||
info.pInputAssemblyState = &iaState;
|
|
||||||
info.pTessellationState = nullptr;
|
|
||||||
info.pViewportState = &vpState;
|
|
||||||
info.pRasterizationState = &rsState;
|
|
||||||
info.pMultisampleState = &msState;
|
|
||||||
info.pColorBlendState = &cbState;
|
|
||||||
info.pDepthStencilState = nullptr;
|
|
||||||
info.pDynamicState = &dynState;
|
|
||||||
info.layout = pipelineLayout;
|
|
||||||
info.renderPass = renderPass;
|
|
||||||
info.subpass = 0;
|
|
||||||
info.basePipelineHandle = VK_NULL_HANDLE;
|
|
||||||
info.basePipelineIndex = -1;
|
|
||||||
|
|
||||||
VkPipeline result = VK_NULL_HANDLE;
|
|
||||||
if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(), VK_NULL_HANDLE, 1, &info, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaMipGenObjects: Failed to create graphics pipeline");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,68 +65,4 @@ namespace dxvk {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Meta resolve objects
|
|
||||||
*
|
|
||||||
* Stores render pass objects and pipelines used
|
|
||||||
* for shader-based resolve operations. Due to
|
|
||||||
* the Vulkan design, we have to create one render
|
|
||||||
* pass and pipeline object per image format used.
|
|
||||||
*/
|
|
||||||
class DxvkMetaResolveObjects : public RcObject {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DxvkMetaResolveObjects(const Rc<vk::DeviceFn>& vkd);
|
|
||||||
~DxvkMetaResolveObjects();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Creates a resolve pipeline
|
|
||||||
*
|
|
||||||
* \param [in] format Image view format
|
|
||||||
* \returns The pipeline handles to use
|
|
||||||
*/
|
|
||||||
DxvkMetaResolvePipeline getPipeline(
|
|
||||||
VkFormat format);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
|
||||||
|
|
||||||
VkSampler m_sampler;
|
|
||||||
|
|
||||||
VkShaderModule m_shaderVert;
|
|
||||||
VkShaderModule m_shaderGeom;
|
|
||||||
VkShaderModule m_shaderFragF;
|
|
||||||
VkShaderModule m_shaderFragI;
|
|
||||||
VkShaderModule m_shaderFragU;
|
|
||||||
|
|
||||||
std::mutex m_mutex;
|
|
||||||
|
|
||||||
std::unordered_map<VkFormat, DxvkMetaResolvePipeline> m_pipelines;
|
|
||||||
|
|
||||||
VkSampler createSampler() const;
|
|
||||||
|
|
||||||
VkShaderModule createShaderModule(
|
|
||||||
const SpirvCodeBuffer& code) const;
|
|
||||||
|
|
||||||
DxvkMetaResolvePipeline createPipeline(
|
|
||||||
VkFormat format);
|
|
||||||
|
|
||||||
VkRenderPass createRenderPass(
|
|
||||||
VkFormat format) const;
|
|
||||||
|
|
||||||
VkDescriptorSetLayout createDescriptorSetLayout() const;
|
|
||||||
|
|
||||||
VkPipelineLayout createPipelineLayout(
|
|
||||||
VkDescriptorSetLayout descriptorSetLayout) const;
|
|
||||||
|
|
||||||
VkPipeline createPipeline(
|
|
||||||
VkPipelineLayout pipelineLayout,
|
|
||||||
VkRenderPass renderPass,
|
|
||||||
VkFormat format) const;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
@ -28,11 +28,8 @@ dxvk_shaders = files([
|
|||||||
'shaders/dxvk_pack_d24s8.comp',
|
'shaders/dxvk_pack_d24s8.comp',
|
||||||
'shaders/dxvk_pack_d32s8.comp',
|
'shaders/dxvk_pack_d32s8.comp',
|
||||||
|
|
||||||
'shaders/dxvk_resolve_vert.vert',
|
|
||||||
'shaders/dxvk_resolve_geom.geom',
|
'shaders/dxvk_resolve_geom.geom',
|
||||||
'shaders/dxvk_resolve_frag_f.frag',
|
'shaders/dxvk_resolve_vert.vert',
|
||||||
'shaders/dxvk_resolve_frag_i.frag',
|
|
||||||
'shaders/dxvk_resolve_frag_u.frag',
|
|
||||||
|
|
||||||
'hud/shaders/hud_line.frag',
|
'hud/shaders/hud_line.frag',
|
||||||
'hud/shaders/hud_text.frag',
|
'hud/shaders/hud_text.frag',
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#version 450
|
|
||||||
|
|
||||||
layout(set = 0, binding = 0)
|
|
||||||
uniform sampler2DMSArray s_image;
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 o_color;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
int sampleCount = textureSamples(s_image);
|
|
||||||
|
|
||||||
o_color = vec4(0.0f);
|
|
||||||
for (int i = 0; i < sampleCount; i++)
|
|
||||||
o_color += texelFetch(s_image, ivec3(gl_FragCoord.xy, gl_Layer), i);
|
|
||||||
o_color /= float(sampleCount);
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
#version 450
|
|
||||||
|
|
||||||
layout(set = 0, binding = 0)
|
|
||||||
uniform isampler2DMSArray s_image;
|
|
||||||
|
|
||||||
layout(location = 0) out ivec4 o_color;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
int sampleCount = textureSamples(s_image);
|
|
||||||
|
|
||||||
o_color = ivec4(0);
|
|
||||||
for (int i = 0; i < sampleCount; i++)
|
|
||||||
o_color += texelFetch(s_image, ivec3(gl_FragCoord.xy, gl_Layer), i) / sampleCount;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
#version 450
|
|
||||||
|
|
||||||
layout(set = 0, binding = 0)
|
|
||||||
uniform usampler2DMSArray s_image;
|
|
||||||
|
|
||||||
layout(location = 0) out uvec4 o_color;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
int sampleCount = textureSamples(s_image);
|
|
||||||
|
|
||||||
o_color = uvec4(0u);
|
|
||||||
for (int i = 0; i < sampleCount; i++)
|
|
||||||
o_color += texelFetch(s_image, ivec3(gl_FragCoord.xy, gl_Layer), i) / uint(sampleCount);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user