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

Method initDeviceLocalTexture

GPCS4/Graphics/Gnm/GnmInitializer.cpp:94–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 }
93
94 void GnmInitializer::initDeviceLocalTexture(
95 const Rc<VltImage>& image, const Texture* tsharp)
96 {
97 std::lock_guard<std::mutex> lock(m_mutex);
98
99 auto formatInfo = imageFormatInfo(image->info().format);
100 auto textureFormat = tsharp->getDataFormat();
101 uint32_t bytesPerElement = textureFormat.getTotalBytesPerElement();
102 bool isCompressed = textureFormat.isBlockCompressedFormat();
103 const uint8_t* textureMem = reinterpret_cast<uint8_t*>(tsharp->getBaseAddress());
104
105 for (uint32_t layer = 0; layer < image->info().numLayers; layer++)
106 {
107 for (uint32_t level = 0; level < image->info().mipLevels; level++)
108 {
109 VkImageSubresourceLayers subresourceLayers;
110 subresourceLayers.aspectMask = formatInfo->aspectMask;
111 subresourceLayers.mipLevel = level;
112 subresourceLayers.baseArrayLayer = layer;
113 subresourceLayers.layerCount = 1;
114
115 GpuAddress::TilingParameters params;
116 params.initFromTexture(tsharp, level, layer);
117 GpuAddress::SurfaceInfo surfaceInfo;
118 GpuAddress::computeSurfaceInfo(&surfaceInfo, &params);
119
120 VkOffset3D mipLevelOffset = { 0, 0, 0 };
121 VkExtent3D mipLevelExtent = image->mipLevelExtent(level);
122
123 m_transferCommands += 1;
124 m_transferMemory += vutil::computeImageDataSize(
125 image->info().format, mipLevelExtent);
126
127 uint32_t elementPerRow = isCompressed ? surfaceInfo.m_pitch / 4 : surfaceInfo.m_pitch;
128 uint32_t pitchInBytes = elementPerRow * bytesPerElement;
129 if (formatInfo->aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))
130 {
131 uint64_t surfaceOffset = 0;
132 uint64_t surfaceSize = 0;
133 GpuAddress::computeTextureSurfaceOffsetAndSize(
134 &surfaceOffset, &surfaceSize, tsharp, level, layer);
135 const void* memory = textureMem + surfaceOffset;
136
137 m_context->uploadImage(
138 image, subresourceLayers,
139 memory,
140 pitchInBytes,
141 surfaceInfo.m_surfaceSize);
142 }
143 else
144 {
145 LOG_ASSERT(false, "TODO");
146 // m_context->updateDepthStencilImage(
147 // image, subresourceLayers,
148 // VkOffset2D{ mipLevelOffset.x, mipLevelOffset.y },
149 // VkExtent2D{ mipLevelExtent.width, mipLevelExtent.height },
150 // pInitialData[id].pSysMem,
151 // pInitialData[id].SysMemPitch,

Callers

nothing calls this directly

Calls 10

imageFormatInfoFunction · 0.85
computeImageDataSizeFunction · 0.85
initFromTextureMethod · 0.80
uploadImageMethod · 0.80
infoMethod · 0.45
getDataFormatMethod · 0.45
getBaseAddressMethod · 0.45
mipLevelExtentMethod · 0.45

Tested by

no test coverage detected