MCPcopy Create free account
hub / github.com/defold/defold / CopyTextureDataMipmapLevel

Function CopyTextureDataMipmapLevel

engine/graphics/src/dx12/graphics_dx12.cpp:1260–1292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1258 }
1259
1260 static void CopyTextureDataMipmapLevel(const TextureParams& params, TextureFormat format_dst, TextureFormat format_src,
1261 const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* layouts, const uint32_t* num_rows, uint32_t array_count,
1262 uint32_t mipmap_count, const uint32_t* slice_row_pitch, const uint8_t* pixels, uint8_t* upload_data, uint32_t mipmap)
1263 {
1264 const uint8_t bpp_dst = GetTextureFormatBitsPerPixel(format_dst) / 8;
1265 const uint8_t bpp_src = GetTextureFormatBitsPerPixel(format_src) / 8;
1266 const uint64_t srcRowPitch = slice_row_pitch[0]; // Assuming only one mip being uploaded
1267 const uint32_t copy_width = params.m_Width;
1268 const uint32_t copy_height = params.m_Height;
1269 const uint32_t copy_x = params.m_X;
1270 const uint32_t copy_y = params.m_Y;
1271
1272 for (uint32_t array = 0; array < array_count; ++array)
1273 {
1274 const D3D12_PLACED_SUBRESOURCE_FOOTPRINT& layout = layouts[array];
1275 const uint64_t dstRowPitch = layout.Footprint.RowPitch;
1276 const uint32_t depth = layout.Footprint.Depth;
1277
1278 uint8_t* dst = upload_data + layout.Offset;
1279 const uint8_t* src = pixels + array * copy_height * srcRowPitch * depth;
1280
1281 for (uint32_t z = 0; z < depth; ++z)
1282 {
1283 for (uint32_t row = 0; row < copy_height; ++row)
1284 {
1285 const uint8_t* src_row = src + (z * copy_height + row) * srcRowPitch;
1286 uint8_t* dst_row = dst + (z * copy_height + row) * dstRowPitch;
1287
1288 memcpy(dst_row, src_row, copy_width * bpp_dst);
1289 }
1290 }
1291 }
1292 }
1293
1294 static inline void CreateOneTimeCommandList(ID3D12Device* device, DX12OneTimeCommandList* cmd_list)
1295 {

Callers 1

Calls 1

Tested by

no test coverage detected