MCPcopy Create free account
hub / github.com/Inori/GPCS4 / createDepthImage

Method createDepthImage

GPCS4/Graphics/Gnm/GnmResourceFactory.cpp:31–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 }
30
31 bool GnmResourceFactory::createDepthImage(
32 const DepthRenderTarget* depthTarget,
33 SceDepthRenderTarget& depthImage)
34 {
35 VltImageCreateInfo imgInfo;
36 imgInfo.type = VK_IMAGE_TYPE_2D;
37 imgInfo.format = cvt::convertZFormat(depthTarget->getZFormat());
38 imgInfo.flags = 0;
39 imgInfo.sampleCount = cvt::convertNumFragments(depthTarget->getNumFragments()); // not really understand..
40 imgInfo.extent.width = depthTarget->getWidth();
41 imgInfo.extent.height = depthTarget->getHeight();
42 imgInfo.extent.depth = 1;
43 // NOTE: this slice count is only valid if the array view hasn't changed since initialization!
44 imgInfo.numLayers = depthTarget->getLastArraySliceIndex() - depthTarget->getBaseArraySliceIndex() + 1;
45 imgInfo.mipLevels = 1;
46 imgInfo.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
47 imgInfo.stages = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
48 imgInfo.access = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
49 imgInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
50 imgInfo.layout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
51
52 VltImageViewCreateInfo viewInfo;
53 viewInfo.type = VK_IMAGE_VIEW_TYPE_2D;
54 viewInfo.format = imgInfo.format;
55 viewInfo.usage = imgInfo.usage;
56 viewInfo.aspect = VK_IMAGE_ASPECT_DEPTH_BIT;
57 viewInfo.minLevel = 0;
58 viewInfo.numLevels = 1;
59 viewInfo.minLayer = 0;
60 viewInfo.numLayers = 1;
61 if (imgInfo.format >= VK_FORMAT_D16_UNORM_S8_UINT)
62 {
63 viewInfo.aspect |= VK_IMAGE_ASPECT_STENCIL_BIT;
64 }
65
66 depthImage.image = m_device->createImage(
67 imgInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
68 depthImage.imageView = m_device->createImageView(
69 depthImage.image, viewInfo);
70 depthImage.depthRenderTarget = *depthTarget;
71
72 // Set debug name
73 auto imageName = fmt::format("DepthTarget_{}_{}",
74 s_objectId++,
75 fmt::ptr(depthTarget->getZReadAddress()));
76 auto viewName = fmt::format("DepthView_{}_{}",
77 s_objectId++,
78 fmt::ptr(depthTarget->getZReadAddress()));
79
80 VkDebugUtilsObjectNameInfoEXT nameInfo;
81 nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
82 nameInfo.pNext = nullptr;
83 nameInfo.objectType = VK_OBJECT_TYPE_IMAGE;
84 nameInfo.pObjectName = imageName.c_str();
85 nameInfo.objectHandle = (uint64_t)depthImage.image->handle();
86 m_debugUtil.setObjectName(&nameInfo);
87
88 nameInfo.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;

Callers 1

getDepthTargetMethod · 0.80

Calls 15

convertZFormatFunction · 0.85
convertNumFragmentsFunction · 0.85
getZReadAddressMethod · 0.80
setObjectNameMethod · 0.80
formatFunction · 0.50
ptrFunction · 0.50
getZFormatMethod · 0.45
getNumFragmentsMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected