mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-14 22:29:15 +01:00
[dxvk] Use dynamic rendering for blits and mip generation
This commit is contained in:
parent
d5cc50f73f
commit
a450c88c72
@ -1553,53 +1553,72 @@ namespace dxvk {
|
|||||||
this->spillRenderPass(false);
|
this->spillRenderPass(false);
|
||||||
this->invalidateState();
|
this->invalidateState();
|
||||||
|
|
||||||
m_execBarriers.recordCommands(m_cmd);
|
// Create image views, etc.
|
||||||
|
Rc<DxvkMetaMipGenRenderPass> mipGenerator = new DxvkMetaMipGenRenderPass(m_device->vkd(), imageView);
|
||||||
|
|
||||||
// Create the a set of framebuffers and image views
|
if (m_execBarriers.isImageDirty(imageView->image(), imageView->imageSubresources(), DxvkAccess::Write))
|
||||||
const Rc<DxvkMetaMipGenRenderPass> mipGenerator
|
m_execBarriers.recordCommands(m_cmd);
|
||||||
= new DxvkMetaMipGenRenderPass(m_device->vkd(), imageView);
|
|
||||||
|
VkImageLayout dstLayout = imageView->pickLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
|
VkImageLayout srcLayout = imageView->pickLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
|
|
||||||
|
// If necessary, transition first mip level to the read-only layout
|
||||||
|
if (imageView->imageInfo().layout != srcLayout) {
|
||||||
|
m_execAcquires.accessImage(imageView->image(),
|
||||||
|
mipGenerator->getTopSubresource(),
|
||||||
|
imageView->imageInfo().layout,
|
||||||
|
imageView->imageInfo().stages, 0,
|
||||||
|
srcLayout,
|
||||||
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
|
VK_ACCESS_SHADER_READ_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If necessary, initialize all levels that are written to
|
||||||
|
if (imageView->imageInfo().layout != dstLayout) {
|
||||||
|
m_execAcquires.accessImage(imageView->image(),
|
||||||
|
mipGenerator->getAllTargetSubresources(),
|
||||||
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
|
imageView->imageInfo().stages, 0,
|
||||||
|
dstLayout,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_execAcquires.recordCommands(m_cmd);
|
||||||
|
|
||||||
// Common descriptor set properties that we use to
|
// Common descriptor set properties that we use to
|
||||||
// bind the source image view to the fragment shader
|
// bind the source image view to the fragment shader
|
||||||
VkDescriptorImageInfo descriptorImage;
|
VkDescriptorImageInfo descriptorImage = { };
|
||||||
descriptorImage.sampler = m_common->metaBlit().getSampler(filter);
|
descriptorImage.sampler = m_common->metaBlit().getSampler(filter);
|
||||||
descriptorImage.imageView = VK_NULL_HANDLE;
|
descriptorImage.imageLayout = srcLayout;
|
||||||
descriptorImage.imageLayout = imageView->imageInfo().layout;
|
|
||||||
|
|
||||||
VkWriteDescriptorSet descriptorWrite;
|
VkWriteDescriptorSet descriptorWrite = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET };
|
||||||
descriptorWrite.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
descriptorWrite.pNext = nullptr;
|
|
||||||
descriptorWrite.dstSet = VK_NULL_HANDLE;
|
|
||||||
descriptorWrite.dstBinding = 0;
|
descriptorWrite.dstBinding = 0;
|
||||||
descriptorWrite.dstArrayElement = 0;
|
descriptorWrite.dstArrayElement = 0;
|
||||||
descriptorWrite.descriptorCount = 1;
|
descriptorWrite.descriptorCount = 1;
|
||||||
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
descriptorWrite.pImageInfo = &descriptorImage;
|
descriptorWrite.pImageInfo = &descriptorImage;
|
||||||
descriptorWrite.pBufferInfo = nullptr;
|
|
||||||
descriptorWrite.pTexelBufferView = nullptr;
|
|
||||||
|
|
||||||
// Common render pass info
|
// Common render pass info
|
||||||
VkRenderPassBeginInfo passInfo;
|
VkRenderingAttachmentInfoKHR attachmentInfo = { VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR };
|
||||||
passInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
attachmentInfo.imageLayout = dstLayout;
|
||||||
passInfo.pNext = nullptr;
|
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
passInfo.renderPass = mipGenerator->renderPass();
|
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
passInfo.framebuffer = VK_NULL_HANDLE;
|
|
||||||
passInfo.renderArea = VkRect2D { };
|
VkRenderingInfoKHR renderingInfo = { VK_STRUCTURE_TYPE_RENDERING_INFO_KHR };
|
||||||
passInfo.clearValueCount = 0;
|
renderingInfo.colorAttachmentCount = 1;
|
||||||
passInfo.pClearValues = nullptr;
|
renderingInfo.pColorAttachments = &attachmentInfo;
|
||||||
|
|
||||||
// Retrieve a compatible pipeline to use for rendering
|
// Retrieve a compatible pipeline to use for rendering
|
||||||
DxvkMetaBlitPipeline pipeInfo = m_common->metaBlit().getPipeline(
|
DxvkMetaBlitPipeline pipeInfo = m_common->metaBlit().getPipeline(
|
||||||
mipGenerator->viewType(), imageView->info().format, VK_SAMPLE_COUNT_1_BIT);
|
mipGenerator->getSrcViewType(), imageView->info().format, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mipGenerator->passCount(); i++) {
|
for (uint32_t i = 0; i < mipGenerator->getPassCount(); i++) {
|
||||||
DxvkMetaBlitPass pass = mipGenerator->pass(i);
|
|
||||||
|
|
||||||
// Width, height and layer count for the current pass
|
// Width, height and layer count for the current pass
|
||||||
VkExtent3D passExtent = mipGenerator->passExtent(i);
|
VkExtent3D passExtent = mipGenerator->computePassExtent(i);
|
||||||
|
|
||||||
// Create descriptor set with the current source view
|
// Create descriptor set with the current source view
|
||||||
descriptorImage.imageView = pass.srcView;
|
descriptorImage.imageView = mipGenerator->getSrcView(i);
|
||||||
descriptorWrite.dstSet = m_descriptorPool->alloc(pipeInfo.dsetLayout);
|
descriptorWrite.dstSet = m_descriptorPool->alloc(pipeInfo.dsetLayout);
|
||||||
m_cmd->updateDescriptorSets(1, &descriptorWrite);
|
m_cmd->updateDescriptorSets(1, &descriptorWrite);
|
||||||
|
|
||||||
@ -1616,17 +1635,30 @@ namespace dxvk {
|
|||||||
scissor.offset = { 0, 0 };
|
scissor.offset = { 0, 0 };
|
||||||
scissor.extent = { passExtent.width, passExtent.height };
|
scissor.extent = { passExtent.width, passExtent.height };
|
||||||
|
|
||||||
// Set up render pass info
|
// Set up rendering info
|
||||||
passInfo.framebuffer = pass.framebuffer;
|
attachmentInfo.imageView = mipGenerator->getDstView(i);
|
||||||
passInfo.renderArea = scissor;
|
renderingInfo.renderArea = scissor;
|
||||||
|
renderingInfo.layerCount = passExtent.depth;
|
||||||
|
|
||||||
// Set up push constants
|
// Set up push constants
|
||||||
DxvkMetaBlitPushConstants pushConstants = { };
|
DxvkMetaBlitPushConstants pushConstants = { };
|
||||||
pushConstants.srcCoord0 = { 0.0f, 0.0f, 0.0f };
|
pushConstants.srcCoord0 = { 0.0f, 0.0f, 0.0f };
|
||||||
pushConstants.srcCoord1 = { 1.0f, 1.0f, 1.0f };
|
pushConstants.srcCoord1 = { 1.0f, 1.0f, 1.0f };
|
||||||
pushConstants.layerCount = passExtent.depth;
|
pushConstants.layerCount = passExtent.depth;
|
||||||
|
|
||||||
m_cmd->cmdBeginRenderPass(&passInfo, VK_SUBPASS_CONTENTS_INLINE);
|
if (i) {
|
||||||
|
m_execAcquires.accessImage(imageView->image(),
|
||||||
|
mipGenerator->getSourceSubresource(i),
|
||||||
|
dstLayout,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
|
srcLayout,
|
||||||
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
|
VK_ACCESS_SHADER_READ_BIT);
|
||||||
|
m_execAcquires.recordCommands(m_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_cmd->cmdBeginRendering(&renderingInfo);
|
||||||
m_cmd->cmdBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeInfo.pipeHandle);
|
m_cmd->cmdBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeInfo.pipeHandle);
|
||||||
m_cmd->cmdBindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS,
|
m_cmd->cmdBindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
pipeInfo.pipeLayout, descriptorWrite.dstSet, 0, nullptr);
|
pipeInfo.pipeLayout, descriptorWrite.dstSet, 0, nullptr);
|
||||||
@ -1641,9 +1673,44 @@ namespace dxvk {
|
|||||||
&pushConstants);
|
&pushConstants);
|
||||||
|
|
||||||
m_cmd->cmdDraw(3, passExtent.depth, 0, 0);
|
m_cmd->cmdDraw(3, passExtent.depth, 0, 0);
|
||||||
m_cmd->cmdEndRenderPass();
|
m_cmd->cmdEndRendering();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue barriers to ensure we can safely access all mip
|
||||||
|
// levels of the image in all ways the image can be used
|
||||||
|
if (srcLayout == dstLayout) {
|
||||||
|
m_execBarriers.accessImage(imageView->image(),
|
||||||
|
imageView->imageSubresources(),
|
||||||
|
srcLayout,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
|
||||||
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
||||||
|
VK_ACCESS_SHADER_READ_BIT,
|
||||||
|
imageView->imageInfo().layout,
|
||||||
|
imageView->imageInfo().stages,
|
||||||
|
imageView->imageInfo().access);
|
||||||
|
} else {
|
||||||
|
m_execBarriers.accessImage(imageView->image(),
|
||||||
|
mipGenerator->getAllSourceSubresources(),
|
||||||
|
srcLayout,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
|
||||||
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
||||||
|
VK_ACCESS_SHADER_READ_BIT,
|
||||||
|
imageView->imageInfo().layout,
|
||||||
|
imageView->imageInfo().stages,
|
||||||
|
imageView->imageInfo().access);
|
||||||
|
|
||||||
|
m_execBarriers.accessImage(imageView->image(),
|
||||||
|
mipGenerator->getBottomSubresource(),
|
||||||
|
dstLayout,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
|
imageView->imageInfo().layout,
|
||||||
|
imageView->imageInfo().stages,
|
||||||
|
imageView->imageInfo().access);
|
||||||
|
}
|
||||||
|
|
||||||
m_cmd->trackResource<DxvkAccess::None>(mipGenerator);
|
m_cmd->trackResource<DxvkAccess::None>(mipGenerator);
|
||||||
m_cmd->trackResource<DxvkAccess::Write>(imageView->image());
|
m_cmd->trackResource<DxvkAccess::Write>(imageView->image());
|
||||||
}
|
}
|
||||||
@ -2508,12 +2575,26 @@ namespace dxvk {
|
|||||||
|| m_execBarriers.isImageDirty(srcImage, srcSubresourceRange, DxvkAccess::Write))
|
|| m_execBarriers.isImageDirty(srcImage, srcSubresourceRange, DxvkAccess::Write))
|
||||||
m_execBarriers.recordCommands(m_cmd);
|
m_execBarriers.recordCommands(m_cmd);
|
||||||
|
|
||||||
bool isDepthStencil = region.srcSubresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
|
bool srcIsDepthStencil = region.srcSubresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||||
|
|
||||||
VkImageLayout srcLayout = srcImage->pickLayout(isDepthStencil
|
VkImageLayout srcLayout = srcImage->pickLayout(srcIsDepthStencil
|
||||||
? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
|
? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
|
||||||
: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
|
|
||||||
|
VkImageLayout dstLayout = dstImage->pickLayout(
|
||||||
|
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
|
|
||||||
|
if (dstImage->info().layout != dstLayout) {
|
||||||
|
m_execAcquires.accessImage(
|
||||||
|
dstImage, dstSubresourceRange,
|
||||||
|
dstImage->info().layout,
|
||||||
|
dstImage->info().stages, 0,
|
||||||
|
dstLayout,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
if (srcImage->info().layout != srcLayout) {
|
if (srcImage->info().layout != srcLayout) {
|
||||||
m_execAcquires.accessImage(
|
m_execAcquires.accessImage(
|
||||||
srcImage, srcSubresourceRange,
|
srcImage, srcSubresourceRange,
|
||||||
@ -2522,10 +2603,10 @@ namespace dxvk {
|
|||||||
srcLayout,
|
srcLayout,
|
||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
VK_ACCESS_SHADER_READ_BIT);
|
VK_ACCESS_SHADER_READ_BIT);
|
||||||
|
|
||||||
m_execAcquires.recordCommands(m_cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_execAcquires.recordCommands(m_cmd);
|
||||||
|
|
||||||
// Sort out image offsets so that dstOffset[0] points
|
// Sort out image offsets so that dstOffset[0] points
|
||||||
// to the top-left corner of the target area
|
// to the top-left corner of the target area
|
||||||
VkOffset3D srcOffsets[2] = { region.srcOffsets[0], region.srcOffsets[1] };
|
VkOffset3D srcOffsets[2] = { region.srcOffsets[0], region.srcOffsets[1] };
|
||||||
@ -2554,24 +2635,24 @@ namespace dxvk {
|
|||||||
// Begin render pass
|
// Begin render pass
|
||||||
Rc<DxvkMetaBlitRenderPass> pass = new DxvkMetaBlitRenderPass(
|
Rc<DxvkMetaBlitRenderPass> pass = new DxvkMetaBlitRenderPass(
|
||||||
m_device, dstImage, srcImage, region, mapping);
|
m_device, dstImage, srcImage, region, mapping);
|
||||||
DxvkMetaBlitPass passObjects = pass->pass();
|
|
||||||
|
|
||||||
VkExtent3D imageExtent = dstImage->mipLevelExtent(region.dstSubresource.mipLevel);
|
VkExtent3D imageExtent = dstImage->mipLevelExtent(region.dstSubresource.mipLevel);
|
||||||
|
|
||||||
VkRect2D renderArea;
|
VkRenderingAttachmentInfoKHR attachmentInfo = { VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR };
|
||||||
renderArea.offset = VkOffset2D { 0, 0 };
|
attachmentInfo.imageView = pass->getDstView();
|
||||||
renderArea.extent = VkExtent2D { imageExtent.width, imageExtent.height };
|
attachmentInfo.imageLayout = dstLayout;
|
||||||
|
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
|
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
|
||||||
VkRenderPassBeginInfo passInfo;
|
VkRenderingInfoKHR renderingInfo = { VK_STRUCTURE_TYPE_RENDERING_INFO_KHR };
|
||||||
passInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
renderingInfo.renderArea = VkRect2D {
|
||||||
passInfo.pNext = nullptr;
|
VkOffset2D { 0, 0 },
|
||||||
passInfo.renderPass = passObjects.renderPass;
|
VkExtent2D { imageExtent.width, imageExtent.height } };
|
||||||
passInfo.framebuffer = passObjects.framebuffer;
|
renderingInfo.layerCount = pass->framebufferLayerCount();
|
||||||
passInfo.renderArea = renderArea;
|
renderingInfo.colorAttachmentCount = 1;
|
||||||
passInfo.clearValueCount = 0;
|
renderingInfo.pColorAttachments = &attachmentInfo;
|
||||||
passInfo.pClearValues = nullptr;
|
|
||||||
|
|
||||||
m_cmd->cmdBeginRenderPass(&passInfo, VK_SUBPASS_CONTENTS_INLINE);
|
m_cmd->cmdBeginRendering(&renderingInfo);
|
||||||
|
|
||||||
// Bind pipeline
|
// Bind pipeline
|
||||||
DxvkMetaBlitPipeline pipeInfo = m_common->metaBlit().getPipeline(
|
DxvkMetaBlitPipeline pipeInfo = m_common->metaBlit().getPipeline(
|
||||||
@ -2598,20 +2679,16 @@ namespace dxvk {
|
|||||||
// Bind source image view
|
// Bind source image view
|
||||||
VkDescriptorImageInfo descriptorImage;
|
VkDescriptorImageInfo descriptorImage;
|
||||||
descriptorImage.sampler = m_common->metaBlit().getSampler(filter);
|
descriptorImage.sampler = m_common->metaBlit().getSampler(filter);
|
||||||
descriptorImage.imageView = passObjects.srcView;
|
descriptorImage.imageView = pass->getSrcView();
|
||||||
descriptorImage.imageLayout = srcLayout;
|
descriptorImage.imageLayout = srcLayout;
|
||||||
|
|
||||||
VkWriteDescriptorSet descriptorWrite;
|
VkWriteDescriptorSet descriptorWrite = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET };
|
||||||
descriptorWrite.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
descriptorWrite.pNext = nullptr;
|
|
||||||
descriptorWrite.dstSet = m_descriptorPool->alloc(pipeInfo.dsetLayout);
|
descriptorWrite.dstSet = m_descriptorPool->alloc(pipeInfo.dsetLayout);
|
||||||
descriptorWrite.dstBinding = 0;
|
descriptorWrite.dstBinding = 0;
|
||||||
descriptorWrite.dstArrayElement = 0;
|
descriptorWrite.dstArrayElement = 0;
|
||||||
descriptorWrite.descriptorCount = 1;
|
descriptorWrite.descriptorCount = 1;
|
||||||
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
descriptorWrite.pImageInfo = &descriptorImage;
|
descriptorWrite.pImageInfo = &descriptorImage;
|
||||||
descriptorWrite.pBufferInfo = nullptr;
|
|
||||||
descriptorWrite.pTexelBufferView = nullptr;
|
|
||||||
|
|
||||||
m_cmd->updateDescriptorSets(1, &descriptorWrite);
|
m_cmd->updateDescriptorSets(1, &descriptorWrite);
|
||||||
m_cmd->cmdBindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS,
|
m_cmd->cmdBindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
@ -2638,12 +2715,12 @@ namespace dxvk {
|
|||||||
&pushConstants);
|
&pushConstants);
|
||||||
|
|
||||||
m_cmd->cmdDraw(3, pushConstants.layerCount, 0, 0);
|
m_cmd->cmdDraw(3, pushConstants.layerCount, 0, 0);
|
||||||
m_cmd->cmdEndRenderPass();
|
m_cmd->cmdEndRendering();
|
||||||
|
|
||||||
// Add barriers and track image objects
|
// Add barriers and track image objects
|
||||||
m_execBarriers.accessImage(dstImage,
|
m_execBarriers.accessImage(dstImage,
|
||||||
vk::makeSubresourceRange(region.dstSubresource),
|
vk::makeSubresourceRange(region.dstSubresource),
|
||||||
dstImage->info().layout,
|
dstLayout,
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
dstImage->info().layout,
|
dstImage->info().layout,
|
||||||
|
@ -22,9 +22,7 @@ namespace dxvk {
|
|||||||
m_srcImage (srcImage),
|
m_srcImage (srcImage),
|
||||||
m_region (region),
|
m_region (region),
|
||||||
m_dstView (createDstView()),
|
m_dstView (createDstView()),
|
||||||
m_srcView (createSrcView(mapping)),
|
m_srcView (createSrcView(mapping)) {
|
||||||
m_renderPass (createRenderPass()),
|
|
||||||
m_framebuffer (createFramebuffer()) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,13 +30,11 @@ namespace dxvk {
|
|||||||
DxvkMetaBlitRenderPass::~DxvkMetaBlitRenderPass() {
|
DxvkMetaBlitRenderPass::~DxvkMetaBlitRenderPass() {
|
||||||
m_vkd->vkDestroyImageView(m_vkd->device(), m_dstView, nullptr);
|
m_vkd->vkDestroyImageView(m_vkd->device(), m_dstView, nullptr);
|
||||||
m_vkd->vkDestroyImageView(m_vkd->device(), m_srcView, nullptr);
|
m_vkd->vkDestroyImageView(m_vkd->device(), m_srcView, nullptr);
|
||||||
m_vkd->vkDestroyRenderPass(m_vkd->device(), m_renderPass, nullptr);
|
|
||||||
m_vkd->vkDestroyFramebuffer(m_vkd->device(), m_framebuffer, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkImageViewType DxvkMetaBlitRenderPass::viewType() const {
|
VkImageViewType DxvkMetaBlitRenderPass::viewType() const {
|
||||||
std::array<VkImageViewType, 3> viewTypes = {{
|
static const std::array<VkImageViewType, 3> viewTypes = {{
|
||||||
VK_IMAGE_VIEW_TYPE_1D_ARRAY,
|
VK_IMAGE_VIEW_TYPE_1D_ARRAY,
|
||||||
VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
||||||
VK_IMAGE_VIEW_TYPE_3D,
|
VK_IMAGE_VIEW_TYPE_3D,
|
||||||
@ -71,16 +67,6 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaBlitPass DxvkMetaBlitRenderPass::pass() const {
|
|
||||||
DxvkMetaBlitPass result;
|
|
||||||
result.srcView = m_srcView;
|
|
||||||
result.dstView = m_dstView;
|
|
||||||
result.renderPass = m_renderPass;
|
|
||||||
result.framebuffer = m_framebuffer;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkImageView DxvkMetaBlitRenderPass::createDstView() {
|
VkImageView DxvkMetaBlitRenderPass::createDstView() {
|
||||||
std::array<VkImageViewType, 3> viewTypes = {{
|
std::array<VkImageViewType, 3> viewTypes = {{
|
||||||
VK_IMAGE_VIEW_TYPE_1D_ARRAY,
|
VK_IMAGE_VIEW_TYPE_1D_ARRAY,
|
||||||
@ -138,75 +124,8 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkRenderPass DxvkMetaBlitRenderPass::createRenderPass() {
|
|
||||||
VkAttachmentDescription attachment;
|
|
||||||
attachment.flags = 0;
|
|
||||||
attachment.format = m_dstImage->info().format;
|
|
||||||
attachment.samples = m_dstImage->info().sampleCount;
|
|
||||||
attachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
|
||||||
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 = m_dstImage->info().layout;
|
|
||||||
attachment.finalLayout = m_dstImage->info().layout;
|
|
||||||
|
|
||||||
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("DxvkMetaBlitRenderPass: Failed to create render pass");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkFramebuffer DxvkMetaBlitRenderPass::createFramebuffer() {
|
|
||||||
VkExtent3D extent = m_dstImage->mipLevelExtent(m_region.dstSubresource.mipLevel);
|
|
||||||
|
|
||||||
VkFramebufferCreateInfo fboInfo;
|
|
||||||
fboInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
|
||||||
fboInfo.pNext = nullptr;
|
|
||||||
fboInfo.flags = 0;
|
|
||||||
fboInfo.renderPass = m_renderPass;
|
|
||||||
fboInfo.attachmentCount = 1;
|
|
||||||
fboInfo.pAttachments = &m_dstView;
|
|
||||||
fboInfo.width = extent.width;
|
|
||||||
fboInfo.height = extent.height;
|
|
||||||
fboInfo.layers = framebufferLayerCount();
|
|
||||||
|
|
||||||
VkFramebuffer result;
|
|
||||||
if (m_vkd->vkCreateFramebuffer(m_vkd->device(), &fboInfo, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaBlitRenderPass: Failed to create target framebuffer");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaBlitObjects::DxvkMetaBlitObjects(const DxvkDevice* device)
|
DxvkMetaBlitObjects::DxvkMetaBlitObjects(const DxvkDevice* device)
|
||||||
: m_vkd (device->vkd()),
|
: m_vkd (device->vkd()),
|
||||||
m_samplerCopy (createSampler(VK_FILTER_NEAREST)),
|
m_samplerCopy (createSampler(VK_FILTER_NEAREST)),
|
||||||
@ -224,9 +143,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
DxvkMetaBlitObjects::~DxvkMetaBlitObjects() {
|
DxvkMetaBlitObjects::~DxvkMetaBlitObjects() {
|
||||||
for (const auto& pair : m_renderPasses)
|
|
||||||
m_vkd->vkDestroyRenderPass(m_vkd->device(), pair.second, nullptr);
|
|
||||||
|
|
||||||
for (const auto& pair : m_pipelines) {
|
for (const auto& pair : m_pipelines) {
|
||||||
m_vkd->vkDestroyPipeline(m_vkd->device(), pair.second.pipeHandle, nullptr);
|
m_vkd->vkDestroyPipeline(m_vkd->device(), pair.second.pipeHandle, nullptr);
|
||||||
m_vkd->vkDestroyPipelineLayout(m_vkd->device(), pair.second.pipeLayout, nullptr);
|
m_vkd->vkDestroyPipelineLayout(m_vkd->device(), pair.second.pipeLayout, nullptr);
|
||||||
@ -272,23 +188,6 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkRenderPass DxvkMetaBlitObjects::getRenderPass(
|
|
||||||
VkFormat viewFormat,
|
|
||||||
VkSampleCountFlagBits samples) {
|
|
||||||
DxvkMetaBlitRenderPassKey key;
|
|
||||||
key.viewFormat = viewFormat;
|
|
||||||
key.samples = samples;
|
|
||||||
|
|
||||||
auto entry = m_renderPasses.find(key);
|
|
||||||
if (entry != m_renderPasses.end())
|
|
||||||
return entry->second;
|
|
||||||
|
|
||||||
VkRenderPass renderPass = this->createRenderPass(viewFormat, samples);
|
|
||||||
m_renderPasses.insert({ key, renderPass });
|
|
||||||
return renderPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkSampler DxvkMetaBlitObjects::createSampler(VkFilter filter) const {
|
VkSampler DxvkMetaBlitObjects::createSampler(VkFilter filter) const {
|
||||||
VkSamplerCreateInfo info;
|
VkSamplerCreateInfo info;
|
||||||
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
@ -337,73 +236,18 @@ namespace dxvk {
|
|||||||
DxvkMetaBlitPipeline pipe;
|
DxvkMetaBlitPipeline pipe;
|
||||||
pipe.dsetLayout = this->createDescriptorSetLayout(key.viewType);
|
pipe.dsetLayout = this->createDescriptorSetLayout(key.viewType);
|
||||||
pipe.pipeLayout = this->createPipelineLayout(pipe.dsetLayout);
|
pipe.pipeLayout = this->createPipelineLayout(pipe.dsetLayout);
|
||||||
pipe.pipeHandle = this->createPipeline(key.viewType, pipe.pipeLayout,
|
pipe.pipeHandle = this->createPipeline(pipe.pipeLayout,
|
||||||
this->getRenderPass(key.viewFormat, key.samples), key.samples);
|
key.viewType, key.viewFormat, key.samples);
|
||||||
return pipe;
|
return pipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkRenderPass DxvkMetaBlitObjects::createRenderPass(
|
|
||||||
VkFormat format,
|
|
||||||
VkSampleCountFlagBits samples) const {
|
|
||||||
VkAttachmentDescription attachment;
|
|
||||||
attachment.flags = 0;
|
|
||||||
attachment.format = format;
|
|
||||||
attachment.samples = samples;
|
|
||||||
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_SHADER_READ_ONLY_OPTIMAL;
|
|
||||||
|
|
||||||
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("DxvkMetaBlitObjects: Failed to create render pass");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkDescriptorSetLayout DxvkMetaBlitObjects::createDescriptorSetLayout(
|
VkDescriptorSetLayout DxvkMetaBlitObjects::createDescriptorSetLayout(
|
||||||
VkImageViewType viewType) const {
|
VkImageViewType viewType) const {
|
||||||
VkDescriptorSetLayoutBinding binding;
|
VkDescriptorSetLayoutBinding binding = { 0,
|
||||||
binding.binding = 0;
|
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT };
|
||||||
binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
|
||||||
binding.descriptorCount = 1;
|
|
||||||
binding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
||||||
binding.pImmutableSamplers = nullptr;
|
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo info;
|
VkDescriptorSetLayoutCreateInfo info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO };
|
||||||
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.bindingCount = 1;
|
info.bindingCount = 1;
|
||||||
info.pBindings = &binding;
|
info.pBindings = &binding;
|
||||||
|
|
||||||
@ -416,15 +260,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkPipelineLayout DxvkMetaBlitObjects::createPipelineLayout(
|
VkPipelineLayout DxvkMetaBlitObjects::createPipelineLayout(
|
||||||
VkDescriptorSetLayout descriptorSetLayout) const {
|
VkDescriptorSetLayout descriptorSetLayout) const {
|
||||||
VkPushConstantRange pushRange;
|
VkPushConstantRange pushRange = { VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(DxvkMetaBlitPushConstants) };
|
||||||
pushRange.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
||||||
pushRange.offset = 0;
|
|
||||||
pushRange.size = sizeof(DxvkMetaBlitPushConstants);
|
|
||||||
|
|
||||||
VkPipelineLayoutCreateInfo info;
|
VkPipelineLayoutCreateInfo info = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO };
|
||||||
info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.setLayoutCount = 1;
|
info.setLayoutCount = 1;
|
||||||
info.pSetLayouts = &descriptorSetLayout;
|
info.pSetLayouts = &descriptorSetLayout;
|
||||||
info.pushConstantRangeCount = 1;
|
info.pushConstantRangeCount = 1;
|
||||||
@ -438,156 +276,90 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
VkPipeline DxvkMetaBlitObjects::createPipeline(
|
VkPipeline DxvkMetaBlitObjects::createPipeline(
|
||||||
VkImageViewType imageViewType,
|
|
||||||
VkPipelineLayout pipelineLayout,
|
VkPipelineLayout pipelineLayout,
|
||||||
VkRenderPass renderPass,
|
VkImageViewType imageViewType,
|
||||||
|
VkFormat format,
|
||||||
VkSampleCountFlagBits samples) const {
|
VkSampleCountFlagBits samples) const {
|
||||||
std::array<VkPipelineShaderStageCreateInfo, 3> stages;
|
std::array<VkPipelineShaderStageCreateInfo, 3> stages;
|
||||||
uint32_t stageCount = 0;
|
uint32_t stageCount = 0;
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo& vsStage = stages[stageCount++];
|
stages[stageCount++] = VkPipelineShaderStageCreateInfo {
|
||||||
vsStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0,
|
||||||
vsStage.pNext = nullptr;
|
VK_SHADER_STAGE_VERTEX_BIT, m_shaderVert, "main" };
|
||||||
vsStage.flags = 0;
|
|
||||||
vsStage.stage = VK_SHADER_STAGE_VERTEX_BIT;
|
|
||||||
vsStage.module = m_shaderVert;
|
|
||||||
vsStage.pName = "main";
|
|
||||||
vsStage.pSpecializationInfo = nullptr;
|
|
||||||
|
|
||||||
if (m_shaderGeom) {
|
if (m_shaderGeom) {
|
||||||
VkPipelineShaderStageCreateInfo& gsStage = stages[stageCount++];
|
stages[stageCount++] = VkPipelineShaderStageCreateInfo {
|
||||||
gsStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0,
|
||||||
gsStage.pNext = nullptr;
|
VK_SHADER_STAGE_GEOMETRY_BIT, m_shaderGeom, "main" };
|
||||||
gsStage.flags = 0;
|
|
||||||
gsStage.stage = VK_SHADER_STAGE_GEOMETRY_BIT;
|
|
||||||
gsStage.module = m_shaderGeom;
|
|
||||||
gsStage.pName = "main";
|
|
||||||
gsStage.pSpecializationInfo = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo& psStage = stages[stageCount++];
|
VkShaderModule psModule = VK_NULL_HANDLE;
|
||||||
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 = VK_NULL_HANDLE;
|
|
||||||
psStage.pName = "main";
|
|
||||||
psStage.pSpecializationInfo = nullptr;
|
|
||||||
|
|
||||||
switch (imageViewType) {
|
switch (imageViewType) {
|
||||||
case VK_IMAGE_VIEW_TYPE_1D_ARRAY: psStage.module = m_shaderFrag1D; break;
|
case VK_IMAGE_VIEW_TYPE_1D_ARRAY: psModule = m_shaderFrag1D; break;
|
||||||
case VK_IMAGE_VIEW_TYPE_2D_ARRAY: psStage.module = m_shaderFrag2D; break;
|
case VK_IMAGE_VIEW_TYPE_2D_ARRAY: psModule = m_shaderFrag2D; break;
|
||||||
case VK_IMAGE_VIEW_TYPE_3D: psStage.module = m_shaderFrag3D; break;
|
case VK_IMAGE_VIEW_TYPE_3D: psModule = m_shaderFrag3D; break;
|
||||||
default: throw DxvkError("DxvkMetaBlitObjects: Invalid view type");
|
default: throw DxvkError("DxvkMetaBlitObjects: Invalid view type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stages[stageCount++] = VkPipelineShaderStageCreateInfo {
|
||||||
|
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0,
|
||||||
|
VK_SHADER_STAGE_FRAGMENT_BIT, psModule, "main" };
|
||||||
|
|
||||||
std::array<VkDynamicState, 2> dynStates = {{
|
std::array<VkDynamicState, 2> dynStates = {{
|
||||||
VK_DYNAMIC_STATE_VIEWPORT,
|
VK_DYNAMIC_STATE_VIEWPORT,
|
||||||
VK_DYNAMIC_STATE_SCISSOR,
|
VK_DYNAMIC_STATE_SCISSOR,
|
||||||
}};
|
}};
|
||||||
|
|
||||||
VkPipelineDynamicStateCreateInfo dynState;
|
VkPipelineDynamicStateCreateInfo dynState = { VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO };
|
||||||
dynState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
dynState.dynamicStateCount = dynStates.size();
|
||||||
dynState.pNext = nullptr;
|
dynState.pDynamicStates = dynStates.data();
|
||||||
dynState.flags = 0;
|
|
||||||
dynState.dynamicStateCount = dynStates.size();
|
|
||||||
dynState.pDynamicStates = dynStates.data();
|
|
||||||
|
|
||||||
VkPipelineVertexInputStateCreateInfo viState;
|
VkPipelineVertexInputStateCreateInfo viState = { VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO };
|
||||||
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;
|
VkPipelineInputAssemblyStateCreateInfo iaState = { VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO };
|
||||||
iaState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
iaState.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||||
iaState.pNext = nullptr;
|
|
||||||
iaState.flags = 0;
|
|
||||||
iaState.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
|
||||||
iaState.primitiveRestartEnable = VK_FALSE;
|
iaState.primitiveRestartEnable = VK_FALSE;
|
||||||
|
|
||||||
VkPipelineViewportStateCreateInfo vpState;
|
VkPipelineViewportStateCreateInfo vpState = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO };
|
||||||
vpState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
vpState.viewportCount = 1;
|
||||||
vpState.pNext = nullptr;
|
vpState.scissorCount = 1;
|
||||||
vpState.flags = 0;
|
|
||||||
vpState.viewportCount = 1;
|
|
||||||
vpState.pViewports = nullptr;
|
|
||||||
vpState.scissorCount = 1;
|
|
||||||
vpState.pScissors = nullptr;
|
|
||||||
|
|
||||||
VkPipelineRasterizationStateCreateInfo rsState;
|
VkPipelineRasterizationStateCreateInfo rsState = { VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO };
|
||||||
rsState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
rsState.polygonMode = VK_POLYGON_MODE_FILL;
|
||||||
rsState.pNext = nullptr;
|
rsState.cullMode = VK_CULL_MODE_NONE;
|
||||||
rsState.flags = 0;
|
rsState.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
||||||
rsState.depthClampEnable = VK_TRUE;
|
rsState.lineWidth = 1.0f;
|
||||||
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;
|
uint32_t msMask = 0xFFFFFFFF;
|
||||||
VkPipelineMultisampleStateCreateInfo msState;
|
VkPipelineMultisampleStateCreateInfo msState = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO };
|
||||||
msState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
|
||||||
msState.pNext = nullptr;
|
|
||||||
msState.flags = 0;
|
|
||||||
msState.rasterizationSamples = samples;
|
msState.rasterizationSamples = samples;
|
||||||
msState.sampleShadingEnable = VK_FALSE;
|
msState.pSampleMask = &msMask;
|
||||||
msState.minSampleShading = 1.0f;
|
|
||||||
msState.pSampleMask = &msMask;
|
|
||||||
msState.alphaToCoverageEnable = VK_FALSE;
|
|
||||||
msState.alphaToOneEnable = VK_FALSE;
|
|
||||||
|
|
||||||
VkPipelineColorBlendAttachmentState cbAttachment;
|
VkPipelineColorBlendAttachmentState cbAttachment = { };
|
||||||
cbAttachment.blendEnable = VK_FALSE;
|
cbAttachment.colorWriteMask =
|
||||||
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_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||||
|
|
||||||
VkPipelineColorBlendStateCreateInfo cbState;
|
VkPipelineColorBlendStateCreateInfo cbState = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO };
|
||||||
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.attachmentCount = 1;
|
||||||
cbState.pAttachments = &cbAttachment;
|
cbState.pAttachments = &cbAttachment;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 4; i++)
|
VkPipelineRenderingCreateInfoKHR rtState = { VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR };
|
||||||
cbState.blendConstants[i] = 0.0f;
|
rtState.colorAttachmentCount = 1;
|
||||||
|
rtState.pColorAttachmentFormats = &format;
|
||||||
VkGraphicsPipelineCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
VkGraphicsPipelineCreateInfo info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, &rtState };
|
||||||
info.pNext = nullptr;
|
|
||||||
info.flags = 0;
|
|
||||||
info.stageCount = stageCount;
|
info.stageCount = stageCount;
|
||||||
info.pStages = stages.data();
|
info.pStages = stages.data();
|
||||||
info.pVertexInputState = &viState;
|
info.pVertexInputState = &viState;
|
||||||
info.pInputAssemblyState = &iaState;
|
info.pInputAssemblyState = &iaState;
|
||||||
info.pTessellationState = nullptr;
|
|
||||||
info.pViewportState = &vpState;
|
info.pViewportState = &vpState;
|
||||||
info.pRasterizationState = &rsState;
|
info.pRasterizationState = &rsState;
|
||||||
info.pMultisampleState = &msState;
|
info.pMultisampleState = &msState;
|
||||||
info.pColorBlendState = &cbState;
|
info.pColorBlendState = &cbState;
|
||||||
info.pDepthStencilState = nullptr;
|
|
||||||
info.pDynamicState = &dynState;
|
info.pDynamicState = &dynState;
|
||||||
info.layout = pipelineLayout;
|
info.layout = pipelineLayout;
|
||||||
info.renderPass = renderPass;
|
|
||||||
info.subpass = 0;
|
|
||||||
info.basePipelineHandle = VK_NULL_HANDLE;
|
|
||||||
info.basePipelineIndex = -1;
|
info.basePipelineIndex = -1;
|
||||||
|
|
||||||
VkPipeline result = VK_NULL_HANDLE;
|
VkPipeline result = VK_NULL_HANDLE;
|
||||||
|
@ -87,20 +87,6 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Blit framebuffer
|
|
||||||
*
|
|
||||||
* Stores the image views and framebuffer
|
|
||||||
* handle used to generate one mip level.
|
|
||||||
*/
|
|
||||||
struct DxvkMetaBlitPass {
|
|
||||||
VkImageView srcView;
|
|
||||||
VkImageView dstView;
|
|
||||||
VkRenderPass renderPass;
|
|
||||||
VkFramebuffer framebuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Blit render pass
|
* \brief Blit render pass
|
||||||
*
|
*
|
||||||
@ -126,7 +112,8 @@ namespace dxvk {
|
|||||||
uint32_t framebufferLayerIndex() const;
|
uint32_t framebufferLayerIndex() const;
|
||||||
uint32_t framebufferLayerCount() const;
|
uint32_t framebufferLayerCount() const;
|
||||||
|
|
||||||
DxvkMetaBlitPass pass() const;
|
VkImageView getDstView() const { return m_dstView; }
|
||||||
|
VkImageView getSrcView() const { return m_srcView; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -137,15 +124,10 @@ namespace dxvk {
|
|||||||
VkImageBlit m_region;
|
VkImageBlit m_region;
|
||||||
VkImageView m_dstView;
|
VkImageView m_dstView;
|
||||||
VkImageView m_srcView;
|
VkImageView m_srcView;
|
||||||
VkRenderPass m_renderPass;
|
|
||||||
VkFramebuffer m_framebuffer;
|
|
||||||
|
|
||||||
VkImageView createDstView();
|
VkImageView createDstView();
|
||||||
VkImageView createSrcView(const VkComponentMapping& mapping);
|
VkImageView createSrcView(const VkComponentMapping& mapping);
|
||||||
|
|
||||||
VkRenderPass createRenderPass();
|
|
||||||
VkFramebuffer createFramebuffer();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -201,20 +183,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
dxvk::mutex m_mutex;
|
dxvk::mutex m_mutex;
|
||||||
|
|
||||||
std::unordered_map<
|
|
||||||
DxvkMetaBlitRenderPassKey,
|
|
||||||
VkRenderPass,
|
|
||||||
DxvkHash, DxvkEq> m_renderPasses;
|
|
||||||
|
|
||||||
std::unordered_map<
|
std::unordered_map<
|
||||||
DxvkMetaBlitPipelineKey,
|
DxvkMetaBlitPipelineKey,
|
||||||
DxvkMetaBlitPipeline,
|
DxvkMetaBlitPipeline,
|
||||||
DxvkHash, DxvkEq> m_pipelines;
|
DxvkHash, DxvkEq> m_pipelines;
|
||||||
|
|
||||||
VkRenderPass getRenderPass(
|
|
||||||
VkFormat viewFormat,
|
|
||||||
VkSampleCountFlagBits samples);
|
|
||||||
|
|
||||||
VkSampler createSampler(
|
VkSampler createSampler(
|
||||||
VkFilter filter) const;
|
VkFilter filter) const;
|
||||||
|
|
||||||
@ -224,10 +197,6 @@ namespace dxvk {
|
|||||||
DxvkMetaBlitPipeline createPipeline(
|
DxvkMetaBlitPipeline createPipeline(
|
||||||
const DxvkMetaBlitPipelineKey& key);
|
const DxvkMetaBlitPipelineKey& key);
|
||||||
|
|
||||||
VkRenderPass createRenderPass(
|
|
||||||
VkFormat format,
|
|
||||||
VkSampleCountFlagBits samples) const;
|
|
||||||
|
|
||||||
VkDescriptorSetLayout createDescriptorSetLayout(
|
VkDescriptorSetLayout createDescriptorSetLayout(
|
||||||
VkImageViewType viewType) const;
|
VkImageViewType viewType) const;
|
||||||
|
|
||||||
@ -235,9 +204,9 @@ namespace dxvk {
|
|||||||
VkDescriptorSetLayout descriptorSetLayout) const;
|
VkDescriptorSetLayout descriptorSetLayout) const;
|
||||||
|
|
||||||
VkPipeline createPipeline(
|
VkPipeline createPipeline(
|
||||||
VkImageViewType imageViewType,
|
|
||||||
VkPipelineLayout pipelineLayout,
|
VkPipelineLayout pipelineLayout,
|
||||||
VkRenderPass renderPass,
|
VkImageViewType imageViewType,
|
||||||
|
VkFormat format,
|
||||||
VkSampleCountFlagBits samples) const;
|
VkSampleCountFlagBits samples) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ namespace dxvk {
|
|||||||
DxvkMetaMipGenRenderPass::DxvkMetaMipGenRenderPass(
|
DxvkMetaMipGenRenderPass::DxvkMetaMipGenRenderPass(
|
||||||
const Rc<vk::DeviceFn>& vkd,
|
const Rc<vk::DeviceFn>& vkd,
|
||||||
const Rc<DxvkImageView>& view)
|
const Rc<DxvkImageView>& view)
|
||||||
: m_vkd(vkd), m_view(view), m_renderPass(createRenderPass()) {
|
: m_vkd(vkd), m_view(view) {
|
||||||
// Determine view type based on image type
|
// Determine view type based on image type
|
||||||
const std::array<std::pair<VkImageViewType, VkImageViewType>, 3> viewTypes = {{
|
const std::array<std::pair<VkImageViewType, VkImageViewType>, 3> viewTypes = {{
|
||||||
{ VK_IMAGE_VIEW_TYPE_1D_ARRAY, VK_IMAGE_VIEW_TYPE_1D_ARRAY },
|
{ VK_IMAGE_VIEW_TYPE_1D_ARRAY, VK_IMAGE_VIEW_TYPE_1D_ARRAY },
|
||||||
@ -20,22 +20,19 @@ namespace dxvk {
|
|||||||
m_passes.resize(view->info().numLevels - 1);
|
m_passes.resize(view->info().numLevels - 1);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < m_passes.size(); i++)
|
for (uint32_t i = 0; i < m_passes.size(); i++)
|
||||||
m_passes.at(i) = this->createFramebuffer(i);
|
m_passes[i] = createViews(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaMipGenRenderPass::~DxvkMetaMipGenRenderPass() {
|
DxvkMetaMipGenRenderPass::~DxvkMetaMipGenRenderPass() {
|
||||||
for (const auto& pass : m_passes) {
|
for (const auto& views : m_passes) {
|
||||||
m_vkd->vkDestroyFramebuffer(m_vkd->device(), pass.framebuffer, nullptr);
|
m_vkd->vkDestroyImageView(m_vkd->device(), views.src, nullptr);
|
||||||
m_vkd->vkDestroyImageView(m_vkd->device(), pass.dstView, nullptr);
|
m_vkd->vkDestroyImageView(m_vkd->device(), views.dst, nullptr);
|
||||||
m_vkd->vkDestroyImageView(m_vkd->device(), pass.srcView, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vkd->vkDestroyRenderPass(m_vkd->device(), m_renderPass, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkExtent3D DxvkMetaMipGenRenderPass::passExtent(uint32_t passId) const {
|
VkExtent3D DxvkMetaMipGenRenderPass::computePassExtent(uint32_t passId) const {
|
||||||
VkExtent3D extent = m_view->mipLevelExtent(passId + 1);
|
VkExtent3D extent = m_view->mipLevelExtent(passId + 1);
|
||||||
|
|
||||||
if (m_view->imageInfo().type != VK_IMAGE_TYPE_3D)
|
if (m_view->imageInfo().type != VK_IMAGE_TYPE_3D)
|
||||||
@ -45,81 +42,14 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkRenderPass DxvkMetaMipGenRenderPass::createRenderPass() const {
|
DxvkMetaMipGenRenderPass::PassViews DxvkMetaMipGenRenderPass::createViews(uint32_t pass) const {
|
||||||
std::array<VkSubpassDependency, 2> subpassDeps = {{
|
PassViews result = { };
|
||||||
{ VK_SUBPASS_EXTERNAL, 0,
|
|
||||||
m_view->imageInfo().stages,
|
VkImageViewUsageCreateInfo usageInfo = { VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO };
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
|
||||||
0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, 0 },
|
VkImageViewCreateInfo viewInfo = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, &usageInfo };
|
||||||
{ 0, VK_SUBPASS_EXTERNAL,
|
viewInfo.image = m_view->imageHandle();
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
viewInfo.format = m_view->info().format;
|
||||||
m_view->imageInfo().stages,
|
|
||||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
|
||||||
m_view->imageInfo().access, 0 },
|
|
||||||
}};
|
|
||||||
|
|
||||||
VkAttachmentDescription attachment;
|
|
||||||
attachment.flags = 0;
|
|
||||||
attachment.format = m_view->info().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 = m_view->imageInfo().layout;
|
|
||||||
|
|
||||||
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 = subpassDeps.size();
|
|
||||||
info.pDependencies = subpassDeps.data();
|
|
||||||
|
|
||||||
VkRenderPass result = VK_NULL_HANDLE;
|
|
||||||
if (m_vkd->vkCreateRenderPass(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaMipGenRenderPass: Failed to create render pass");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DxvkMetaBlitPass DxvkMetaMipGenRenderPass::createFramebuffer(uint32_t pass) const {
|
|
||||||
DxvkMetaBlitPass result;
|
|
||||||
result.srcView = VK_NULL_HANDLE;
|
|
||||||
result.dstView = VK_NULL_HANDLE;
|
|
||||||
result.renderPass = m_renderPass;
|
|
||||||
result.framebuffer = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
// Common image view info
|
|
||||||
VkImageViewCreateInfo viewInfo;
|
|
||||||
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
|
||||||
viewInfo.pNext = nullptr;
|
|
||||||
viewInfo.flags = 0;
|
|
||||||
viewInfo.image = m_view->imageHandle();
|
|
||||||
viewInfo.format = m_view->info().format;
|
|
||||||
viewInfo.components = {
|
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY };
|
|
||||||
|
|
||||||
// Create source image view, which points to
|
// Create source image view, which points to
|
||||||
// the one mip level we're going to sample.
|
// the one mip level we're going to sample.
|
||||||
@ -130,10 +60,11 @@ namespace dxvk {
|
|||||||
srcSubresources.baseArrayLayer = m_view->info().minLayer;
|
srcSubresources.baseArrayLayer = m_view->info().minLayer;
|
||||||
srcSubresources.layerCount = m_view->info().numLayers;
|
srcSubresources.layerCount = m_view->info().numLayers;
|
||||||
|
|
||||||
viewInfo.viewType = m_srcViewType;
|
usageInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
|
viewInfo.viewType = m_srcViewType;
|
||||||
viewInfo.subresourceRange = srcSubresources;
|
viewInfo.subresourceRange = srcSubresources;
|
||||||
|
|
||||||
if (m_vkd->vkCreateImageView(m_vkd->device(), &viewInfo, nullptr, &result.srcView) != VK_SUCCESS)
|
if (m_vkd->vkCreateImageView(m_vkd->device(), &viewInfo, nullptr, &result.src) != VK_SUCCESS)
|
||||||
throw DxvkError("DxvkMetaMipGenRenderPass: Failed to create source image view");
|
throw DxvkError("DxvkMetaMipGenRenderPass: Failed to create source image view");
|
||||||
|
|
||||||
// Create destination image view, which points
|
// Create destination image view, which points
|
||||||
@ -147,34 +78,19 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (m_view->imageInfo().type != VK_IMAGE_TYPE_3D) {
|
if (m_view->imageInfo().type != VK_IMAGE_TYPE_3D) {
|
||||||
dstSubresources.baseArrayLayer = m_view->info().minLayer;
|
dstSubresources.baseArrayLayer = m_view->info().minLayer;
|
||||||
dstSubresources.layerCount = m_view->info().numLayers;
|
dstSubresources.layerCount = m_view->info().numLayers;
|
||||||
} else {
|
} else {
|
||||||
dstSubresources.baseArrayLayer = 0;
|
dstSubresources.baseArrayLayer = 0;
|
||||||
dstSubresources.layerCount = dstExtent.depth;
|
dstSubresources.layerCount = dstExtent.depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewInfo.viewType = m_dstViewType;
|
usageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
|
viewInfo.viewType = m_dstViewType;
|
||||||
viewInfo.subresourceRange = dstSubresources;
|
viewInfo.subresourceRange = dstSubresources;
|
||||||
|
|
||||||
if (m_vkd->vkCreateImageView(m_vkd->device(), &viewInfo, nullptr, &result.dstView) != VK_SUCCESS)
|
if (m_vkd->vkCreateImageView(m_vkd->device(), &viewInfo, nullptr, &result.dst) != VK_SUCCESS)
|
||||||
throw DxvkError("DxvkMetaMipGenRenderPass: Failed to create target image view");
|
throw DxvkError("DxvkMetaMipGenRenderPass: Failed to create destination image view");
|
||||||
|
|
||||||
// Create framebuffer using the destination
|
|
||||||
// image view as its color attachment.
|
|
||||||
VkFramebufferCreateInfo fboInfo;
|
|
||||||
fboInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
|
||||||
fboInfo.pNext = nullptr;
|
|
||||||
fboInfo.flags = 0;
|
|
||||||
fboInfo.renderPass = m_renderPass;
|
|
||||||
fboInfo.attachmentCount = 1;
|
|
||||||
fboInfo.pAttachments = &result.dstView;
|
|
||||||
fboInfo.width = dstExtent.width;
|
|
||||||
fboInfo.height = dstExtent.height;
|
|
||||||
fboInfo.layers = dstSubresources.layerCount;
|
|
||||||
|
|
||||||
if (m_vkd->vkCreateFramebuffer(m_vkd->device(), &fboInfo, nullptr, &result.framebuffer) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkMetaMipGenRenderPass: Failed to create target framebuffer");
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,14 +23,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
~DxvkMetaMipGenRenderPass();
|
~DxvkMetaMipGenRenderPass();
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Render pass handle
|
|
||||||
* \returns Render pass handle
|
|
||||||
*/
|
|
||||||
VkRenderPass renderPass() const {
|
|
||||||
return m_renderPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Source image view type
|
* \brief Source image view type
|
||||||
*
|
*
|
||||||
@ -38,7 +30,7 @@ namespace dxvk {
|
|||||||
* resource descriptor needs to have.
|
* resource descriptor needs to have.
|
||||||
* \returns Source image view type
|
* \returns Source image view type
|
||||||
*/
|
*/
|
||||||
VkImageViewType viewType() const {
|
VkImageViewType getSrcViewType() const {
|
||||||
return m_srcViewType;
|
return m_srcViewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,45 +40,109 @@ namespace dxvk {
|
|||||||
* Number of mip levels to generate.
|
* Number of mip levels to generate.
|
||||||
* \returns Render pass count
|
* \returns Render pass count
|
||||||
*/
|
*/
|
||||||
uint32_t passCount() const {
|
uint32_t getPassCount() const {
|
||||||
return m_passes.size();
|
return m_passes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Framebuffer handles
|
* \brief Source image view
|
||||||
*
|
*
|
||||||
* Returns image view and framebuffer handles
|
|
||||||
* required to generate a single mip level.
|
|
||||||
* \param [in] pass Render pass index
|
* \param [in] pass Render pass index
|
||||||
* \returns Object handles for the given pass
|
* \returns Source image view handle for the given pass
|
||||||
*/
|
*/
|
||||||
DxvkMetaBlitPass pass(uint32_t passId) const {
|
VkImageView getSrcView(uint32_t passId) const {
|
||||||
return m_passes.at(passId);
|
return m_passes.at(passId).src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Destination image view
|
||||||
|
*
|
||||||
|
* \param [in] pass Render pass index
|
||||||
|
* \returns Destination image view handle for the given pass
|
||||||
|
*/
|
||||||
|
VkImageView getDstView(uint32_t passId) const {
|
||||||
|
return m_passes.at(passId).dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns subresource that will only be read
|
||||||
|
* \returns Top level of the image view
|
||||||
|
*/
|
||||||
|
VkImageSubresourceRange getTopSubresource() const {
|
||||||
|
VkImageSubresourceRange sr = m_view->imageSubresources();
|
||||||
|
sr.levelCount = 1;
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns subresource that will only be written
|
||||||
|
* \returns Top level of the image view
|
||||||
|
*/
|
||||||
|
VkImageSubresourceRange getBottomSubresource() const {
|
||||||
|
VkImageSubresourceRange sr = m_view->imageSubresources();
|
||||||
|
sr.baseMipLevel += sr.levelCount - 1;
|
||||||
|
sr.levelCount = 1;
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns all subresources that will be written
|
||||||
|
* \returns All mip levels except the top level
|
||||||
|
*/
|
||||||
|
VkImageSubresourceRange getAllTargetSubresources() const {
|
||||||
|
VkImageSubresourceRange sr = m_view->imageSubresources();
|
||||||
|
sr.baseMipLevel += 1;
|
||||||
|
sr.levelCount -= 1;
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns all subresources that will be read
|
||||||
|
* \returns All mip levels except the bottom level
|
||||||
|
*/
|
||||||
|
VkImageSubresourceRange getAllSourceSubresources() const {
|
||||||
|
VkImageSubresourceRange sr = m_view->imageSubresources();
|
||||||
|
sr.levelCount -= 1;
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns subresource read in a given pass
|
||||||
|
*
|
||||||
|
* \param [in] pass Pass index
|
||||||
|
* \returns The source subresource
|
||||||
|
*/
|
||||||
|
VkImageSubresourceRange getSourceSubresource(uint32_t pass) const {
|
||||||
|
VkImageSubresourceRange sr = m_view->imageSubresources();
|
||||||
|
sr.baseMipLevel += pass;
|
||||||
|
sr.levelCount = 1;
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Framebuffer size for a given pass
|
* \brief Framebuffer size for a given pass
|
||||||
*
|
*
|
||||||
* Stores the width, height, and layer count
|
* Stores the width, height, and layer count
|
||||||
* of the framebuffer for the given pass ID.
|
* of the framebuffer for the given pass ID.
|
||||||
*/
|
*/
|
||||||
VkExtent3D passExtent(uint32_t passId) const;
|
VkExtent3D computePassExtent(uint32_t passId) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
struct PassViews {
|
||||||
|
VkImageView src;
|
||||||
|
VkImageView dst;
|
||||||
|
};
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
Rc<vk::DeviceFn> m_vkd;
|
||||||
Rc<DxvkImageView> m_view;
|
Rc<DxvkImageView> m_view;
|
||||||
|
|
||||||
VkRenderPass m_renderPass;
|
|
||||||
|
|
||||||
VkImageViewType m_srcViewType;
|
VkImageViewType m_srcViewType;
|
||||||
VkImageViewType m_dstViewType;
|
VkImageViewType m_dstViewType;
|
||||||
|
|
||||||
std::vector<DxvkMetaBlitPass> m_passes;
|
std::vector<PassViews> m_passes;
|
||||||
|
|
||||||
VkRenderPass createRenderPass() const;
|
PassViews createViews(uint32_t pass) const;
|
||||||
|
|
||||||
DxvkMetaBlitPass createFramebuffer(uint32_t pass) const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user