Merge pull request #1365 from vlj/d3d12

D3d12: Some fixes
This commit is contained in:
Ivan 2015-12-24 13:39:44 +03:00
commit 813e753e3d
6 changed files with 89 additions and 50 deletions

View File

@ -85,6 +85,9 @@
<Lib> <Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Lib> </Lib>
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
<Lib> <Lib>
@ -92,16 +95,25 @@
<AdditionalDependencies /> <AdditionalDependencies />
<AdditionalLibraryDirectories /> <AdditionalLibraryDirectories />
</Lib> </Lib>
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Lib> <Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Lib> </Lib>
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Lib> <Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Lib> </Lib>
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
<Lib> <Lib>
@ -109,6 +121,9 @@
<AdditionalDependencies /> <AdditionalDependencies />
<AdditionalLibraryDirectories /> <AdditionalLibraryDirectories />
</Lib> </Lib>
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Emu\RSX\D3D12\D3D12Utils.h" /> <ClInclude Include="Emu\RSX\D3D12\D3D12Utils.h" />

View File

@ -13,11 +13,10 @@ namespace
struct texel_rgba struct texel_rgba
{ {
template<size_t block_size> template<size_t block_size>
static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) static void copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block)
{ {
for (unsigned row = 0; row < row_count; row++) for (unsigned row = 0; row < row_count; row++)
memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)src + row * src_pitch_in_block * block_size, width_in_block * block_size); memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)src + row * src_pitch_in_block * block_size, width_in_block * block_size);
return row_count * src_pitch_in_block * block_size;
} }
}; };
@ -28,7 +27,7 @@ struct texel_rgba
struct texel_16b_swizzled struct texel_16b_swizzled
{ {
template<size_t block_size> template<size_t block_size>
static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) static void copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block)
{ {
u16 *castedSrc = static_cast<u16*>(src), *castedDst = static_cast<u16*>(dst); u16 *castedSrc = static_cast<u16*>(src), *castedDst = static_cast<u16*>(dst);
@ -40,7 +39,6 @@ struct texel_16b_swizzled
u16 tmp = temp_swizzled[row * src_pitch_in_block + j]; u16 tmp = temp_swizzled[row * src_pitch_in_block + j];
castedDst[row * dst_pitch_in_block + j] = (tmp >> 8) | (tmp << 8); castedDst[row * dst_pitch_in_block + j] = (tmp >> 8) | (tmp << 8);
} }
return row_count * src_pitch_in_block * block_size;
} }
}; };
@ -50,7 +48,7 @@ struct texel_16b_swizzled
struct texel_rgba_swizzled struct texel_rgba_swizzled
{ {
template<size_t block_size> template<size_t block_size>
static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) static void copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block)
{ {
u32 *castedSrc, *castedDst; u32 *castedSrc, *castedDst;
castedSrc = (u32*)src; castedSrc = (u32*)src;
@ -59,7 +57,6 @@ struct texel_rgba_swizzled
rsx::convert_linear_swizzle<u32>(castedSrc, temp_swizzled.get(), src_pitch_in_block, row_count, true); rsx::convert_linear_swizzle<u32>(castedSrc, temp_swizzled.get(), src_pitch_in_block, row_count, true);
for (unsigned row = 0; row < row_count; row++) for (unsigned row = 0; row < row_count; row++)
memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)temp_swizzled.get() + row * src_pitch_in_block * block_size, width_in_block * block_size); memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)temp_swizzled.get() + row * src_pitch_in_block * block_size, width_in_block * block_size);
return row_count * src_pitch_in_block * block_size;
} }
}; };
@ -69,11 +66,10 @@ struct texel_rgba_swizzled
*/ */
struct texel_bc_format { struct texel_bc_format {
template<size_t block_size> template<size_t block_size>
static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) static void copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block)
{ {
for (unsigned row = 0; row < row_count; row++) for (unsigned row = 0; row < row_count; row++)
memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)src + row * width_in_block * block_size, width_in_block * block_size); memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)src + row * src_pitch_in_block * block_size, width_in_block * block_size);
return width_in_block * row_count * block_size;
} }
}; };
@ -82,7 +78,7 @@ struct texel_bc_format {
*/ */
struct texel_16b_format { struct texel_16b_format {
template<size_t block_size> template<size_t block_size>
static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) static void copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block)
{ {
unsigned short *castedDst = (unsigned short *)dst, *castedSrc = (unsigned short *)src; unsigned short *castedDst = (unsigned short *)dst, *castedSrc = (unsigned short *)src;
@ -92,7 +88,6 @@ struct texel_16b_format {
u16 tmp = castedSrc[row * src_pitch_in_block + j]; u16 tmp = castedSrc[row * src_pitch_in_block + j];
castedDst[row * dst_pitch_in_block + j] = (tmp >> 8) | (tmp << 8); castedDst[row * dst_pitch_in_block + j] = (tmp >> 8) | (tmp << 8);
} }
return row_count * src_pitch_in_block * block_size;
} }
}; };
@ -101,7 +96,7 @@ struct texel_16b_format {
*/ */
struct texel_16bX4_format { struct texel_16bX4_format {
template<size_t block_size> template<size_t block_size>
static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) static void copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block)
{ {
unsigned short *casted_dst = (unsigned short *)dst, *casted_src = (unsigned short *)src; unsigned short *casted_dst = (unsigned short *)dst, *casted_src = (unsigned short *)src;
for (unsigned row = 0; row < row_count; row++) for (unsigned row = 0; row < row_count; row++)
@ -110,28 +105,34 @@ struct texel_16bX4_format {
u16 tmp = casted_src[row * src_pitch_in_block * 4 + j]; u16 tmp = casted_src[row * src_pitch_in_block * 4 + j];
casted_dst[row * dst_pitch_in_block * 4 + j] = (tmp >> 8) | (tmp << 8); casted_dst[row * dst_pitch_in_block * 4 + j] = (tmp >> 8) | (tmp << 8);
} }
return row_count * src_pitch_in_block * block_size;
} }
}; };
/** /**
* Texture upload template. * Texture upload template.
*
* Source textures are stored as following (for power of 2 textures):
* - For linear texture every mipmap level share rowpitch (which is the one of mipmap 0). This means that for non 0 mipmap there's padding between row.
* - For swizzled texture row pitch is texture width X pixel/block size. There's not padding between row.
* - There is no padding between 2 mipmap levels. This means that next mipmap level starts at offset rowpitch X row count
* - Cubemap images are 128 bytes aligned.
*
* The template iterates over all depth (including cubemap) and over all mipmaps. * The template iterates over all depth (including cubemap) and over all mipmaps.
* The alignment is 256 for mipmap levels and 512 for depth (TODO: make this customisable for Vulkan ?) * The alignment is 256 for mipmap levels and 512 for depth (TODO: make this customisable for Vulkan ?)
* The template takes a struct with a "copy_mipmap_level" static function that copy the given mipmap level and returns the offset to add to the src buffer for next * The template takes a struct with a "copy_mipmap_level" static function that copy the given mipmap level and returns the offset to add to the src buffer for next
* mipmap level (to allow same code for packed/non packed texels) * mipmap level (to allow same code for packed/non packed texels)
*/ */
template <typename T, size_t block_size_in_bytes, size_t block_edge_in_texel = 1> template <typename T, bool padded_row, size_t block_size_in_bytes, size_t block_edge_in_texel>
std::vector<MipmapLevelInfo> copy_texture_data(void *dst, const void *src, size_t widthInBlock, size_t heightInBlock, size_t depth, size_t mipmapCount) std::vector<MipmapLevelInfo> copy_texture_data(void *dst, const void *src, size_t width_in_texel, size_t height_in_texel, size_t depth, size_t mipmap_count)
{ {
std::vector<MipmapLevelInfo> Result; std::vector<MipmapLevelInfo> Result;
size_t offsetInDst = 0, offsetInSrc = 0; size_t offsetInDst = 0, offsetInSrc = 0;
// Every mipmap level of rsx textures use the same rowpitch. size_t texture_height_in_block = (height_in_texel + block_edge_in_texel - 1) / block_edge_in_texel;
size_t src_pitch = widthInBlock; size_t texture_width_in_block = (width_in_texel + block_edge_in_texel - 1) / block_edge_in_texel;
for (unsigned depth_level = 0; depth_level < depth; depth_level++) for (unsigned depth_level = 0; depth_level < depth; depth_level++)
{ {
size_t miplevel_height_in_block = heightInBlock, miplevel_width_in_block = widthInBlock; size_t miplevel_height_in_block = texture_height_in_block, miplevel_width_in_block = texture_width_in_block;
for (unsigned mip_level = 0; mip_level < mipmapCount; mip_level++) for (unsigned mip_level = 0; mip_level < mipmap_count; mip_level++)
{ {
size_t dst_pitch = align(miplevel_width_in_block * block_size_in_bytes, 256) / block_size_in_bytes; size_t dst_pitch = align(miplevel_width_in_block * block_size_in_bytes, 256) / block_size_in_bytes;
@ -142,7 +143,16 @@ std::vector<MipmapLevelInfo> copy_texture_data(void *dst, const void *src, size_
currentMipmapLevelInfo.rowPitch = dst_pitch * block_size_in_bytes; currentMipmapLevelInfo.rowPitch = dst_pitch * block_size_in_bytes;
Result.push_back(currentMipmapLevelInfo); Result.push_back(currentMipmapLevelInfo);
offsetInSrc += T::template copy_mipmap_level<block_size_in_bytes>((char*)dst + offsetInDst, (char*)src + offsetInSrc, miplevel_height_in_block, miplevel_width_in_block, dst_pitch, src_pitch); if (!padded_row)
{
T::template copy_mipmap_level<block_size_in_bytes>((char*)dst + offsetInDst, (char*)src + offsetInSrc, miplevel_height_in_block, miplevel_width_in_block, dst_pitch, miplevel_width_in_block);
offsetInSrc += miplevel_height_in_block * miplevel_width_in_block * block_size_in_bytes;
}
else
{
T::template copy_mipmap_level<block_size_in_bytes>((char*)dst + offsetInDst, (char*)src + offsetInSrc, miplevel_height_in_block, miplevel_width_in_block, dst_pitch, texture_width_in_block);
offsetInSrc += miplevel_height_in_block * texture_width_in_block * block_size_in_bytes;
}
offsetInDst += align(miplevel_height_in_block * dst_pitch * block_size_in_bytes, 512); offsetInDst += align(miplevel_height_in_block * dst_pitch * block_size_in_bytes, 512);
miplevel_height_in_block = MAX2(miplevel_height_in_block / 2, 1); miplevel_height_in_block = MAX2(miplevel_height_in_block / 2, 1);
miplevel_width_in_block = MAX2(miplevel_width_in_block / 2, 1); miplevel_width_in_block = MAX2(miplevel_width_in_block / 2, 1);
@ -256,16 +266,11 @@ std::vector<MipmapLevelInfo> upload_placed_texture(const rsx::texture &texture,
{ {
size_t w = texture.width(), h = texture.height(); size_t w = texture.width(), h = texture.height();
size_t depth = texture.depth(); size_t depth = texture.depth();
if (depth == 0) depth = 1;
if (texture.cubemap()) depth *= 6; if (texture.cubemap()) depth *= 6;
int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
size_t blockSizeInByte = get_texture_block_size(format);
size_t blockEdge = get_texture_block_edge(format);
size_t heightInBlocks = (h + blockEdge - 1) / blockEdge;
size_t widthInBlocks = (w + blockEdge - 1) / blockEdge;
std::vector<MipmapLevelInfo> mipInfos; std::vector<MipmapLevelInfo> mipInfos;
const u32 texaddr = rsx::get_address(texture.offset(), texture.location()); const u32 texaddr = rsx::get_address(texture.offset(), texture.location());
@ -275,28 +280,37 @@ std::vector<MipmapLevelInfo> upload_placed_texture(const rsx::texture &texture,
{ {
case CELL_GCM_TEXTURE_A8R8G8B8: case CELL_GCM_TEXTURE_A8R8G8B8:
if (is_swizzled) if (is_swizzled)
return copy_texture_data<texel_rgba_swizzled, 4, 1>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); return copy_texture_data<texel_rgba_swizzled, false, 4, 1>(textureData, pixels, w, h, depth, texture.mipmap());
else else
return copy_texture_data<texel_rgba, 4, 1>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); return copy_texture_data<texel_rgba, true, 4, 1>(textureData, pixels, w, h, depth, texture.mipmap());
case CELL_GCM_TEXTURE_A1R5G5B5: case CELL_GCM_TEXTURE_A1R5G5B5:
case CELL_GCM_TEXTURE_A4R4G4B4: case CELL_GCM_TEXTURE_A4R4G4B4:
case CELL_GCM_TEXTURE_R5G6B5: case CELL_GCM_TEXTURE_R5G6B5:
if (is_swizzled) if (is_swizzled)
return copy_texture_data<texel_16b_swizzled, 2, 1>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); return copy_texture_data<texel_16b_swizzled, false, 2, 1>(textureData, pixels, w, h, depth, texture.mipmap());
else else
return copy_texture_data<texel_16b_format, 2, 1>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); return copy_texture_data<texel_16b_format, true, 2, 1>(textureData, pixels, w, h, depth, texture.mipmap());
case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT:
return copy_texture_data<texel_16bX4_format, 8, 1>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); return copy_texture_data<texel_16bX4_format, true, 8, 1>(textureData, pixels, w, h, depth, texture.mipmap());
case CELL_GCM_TEXTURE_COMPRESSED_DXT1: case CELL_GCM_TEXTURE_COMPRESSED_DXT1:
return copy_texture_data<texel_bc_format, 8, 4>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); if (is_swizzled)
return copy_texture_data<texel_bc_format, false, 8, 4>(textureData, pixels, w, h, depth, texture.mipmap());
else
return copy_texture_data<texel_bc_format, true, 8, 4>(textureData, pixels, w, h, depth, texture.mipmap());
case CELL_GCM_TEXTURE_COMPRESSED_DXT23: case CELL_GCM_TEXTURE_COMPRESSED_DXT23:
return copy_texture_data<texel_bc_format, 16, 4>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); if (is_swizzled)
return copy_texture_data<texel_bc_format, false, 16, 4>(textureData, pixels, w, h, depth, texture.mipmap());
else
return copy_texture_data<texel_bc_format, true, 16, 4>(textureData, pixels, w, h, depth, texture.mipmap());
case CELL_GCM_TEXTURE_COMPRESSED_DXT45: case CELL_GCM_TEXTURE_COMPRESSED_DXT45:
return copy_texture_data<texel_bc_format, 16, 4>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); if (is_swizzled)
return copy_texture_data<texel_bc_format, false, 16, 4>(textureData, pixels, w, h, depth, texture.mipmap());
else
return copy_texture_data<texel_bc_format, true, 16, 4>(textureData, pixels, w, h, depth, texture.mipmap());
case CELL_GCM_TEXTURE_B8: case CELL_GCM_TEXTURE_B8:
return copy_texture_data<texel_rgba, 1, 1>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); return copy_texture_data<texel_rgba, true, 1, 1>(textureData, pixels, w, h, depth, texture.mipmap());
default: default:
return copy_texture_data<texel_rgba, 4, 1>(textureData, pixels, widthInBlocks, heightInBlocks, depth, texture.mipmap()); return copy_texture_data<texel_rgba, true, 4, 1>(textureData, pixels, w, h, depth, texture.mipmap());
} }
} }

View File

@ -53,15 +53,15 @@ D3D12_BLEND get_blend_factor_alpha(u16 factor)
{ {
case CELL_GCM_ZERO: return D3D12_BLEND_ZERO; case CELL_GCM_ZERO: return D3D12_BLEND_ZERO;
case CELL_GCM_ONE: return D3D12_BLEND_ONE; case CELL_GCM_ONE: return D3D12_BLEND_ONE;
case CELL_GCM_SRC_COLOR: return D3D12_BLEND_SRC_ALPHA; case CELL_GCM_SRC_COLOR: return D3D12_BLEND_SRC_COLOR;
case CELL_GCM_ONE_MINUS_SRC_COLOR: return D3D12_BLEND_INV_SRC_ALPHA; case CELL_GCM_ONE_MINUS_SRC_COLOR: return D3D12_BLEND_INV_SRC_COLOR;
case CELL_GCM_SRC_ALPHA: return D3D12_BLEND_SRC_ALPHA; case CELL_GCM_SRC_ALPHA: return D3D12_BLEND_SRC_ALPHA;
case CELL_GCM_ONE_MINUS_SRC_ALPHA: return D3D12_BLEND_INV_SRC_ALPHA; case CELL_GCM_ONE_MINUS_SRC_ALPHA: return D3D12_BLEND_INV_SRC_ALPHA;
case CELL_GCM_DST_ALPHA: return D3D12_BLEND_DEST_ALPHA; case CELL_GCM_DST_ALPHA: return D3D12_BLEND_DEST_ALPHA;
case CELL_GCM_ONE_MINUS_DST_ALPHA: return D3D12_BLEND_INV_DEST_ALPHA; case CELL_GCM_ONE_MINUS_DST_ALPHA: return D3D12_BLEND_INV_DEST_ALPHA;
case CELL_GCM_DST_COLOR: return D3D12_BLEND_DEST_ALPHA; case CELL_GCM_DST_COLOR: return D3D12_BLEND_DEST_COLOR;
case CELL_GCM_ONE_MINUS_DST_COLOR: return D3D12_BLEND_INV_DEST_COLOR; case CELL_GCM_ONE_MINUS_DST_COLOR: return D3D12_BLEND_INV_DEST_COLOR;
case CELL_GCM_SRC_ALPHA_SATURATE: return D3D12_BLEND_INV_DEST_ALPHA; case CELL_GCM_SRC_ALPHA_SATURATE: return D3D12_BLEND_SRC_ALPHA_SAT;
case CELL_GCM_CONSTANT_COLOR: case CELL_GCM_CONSTANT_COLOR:
case CELL_GCM_ONE_MINUS_CONSTANT_COLOR: case CELL_GCM_ONE_MINUS_CONSTANT_COLOR:
case CELL_GCM_CONSTANT_ALPHA: case CELL_GCM_CONSTANT_ALPHA:
@ -154,7 +154,7 @@ DXGI_FORMAT get_texture_format(u8 format)
case CELL_GCM_TEXTURE_DEPTH16_FLOAT: return DXGI_FORMAT_R16_FLOAT; case CELL_GCM_TEXTURE_DEPTH16_FLOAT: return DXGI_FORMAT_R16_FLOAT;
case CELL_GCM_TEXTURE_X16: return DXGI_FORMAT_R16_UNORM; case CELL_GCM_TEXTURE_X16: return DXGI_FORMAT_R16_UNORM;
case CELL_GCM_TEXTURE_Y16_X16: return DXGI_FORMAT_R16G16_UNORM; case CELL_GCM_TEXTURE_Y16_X16: return DXGI_FORMAT_R16G16_UNORM;
case CELL_GCM_TEXTURE_R5G5B5A1: return DXGI_FORMAT_R8G8B8A8_UNORM; case CELL_GCM_TEXTURE_R5G5B5A1: return DXGI_FORMAT_B5G5R5A1_UNORM;
case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: return DXGI_FORMAT_R16G16B16A16_FLOAT; case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: return DXGI_FORMAT_R16G16B16A16_FLOAT;
case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: return DXGI_FORMAT_R32G32B32A32_FLOAT; case CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT: return DXGI_FORMAT_R32G32B32A32_FLOAT;
case CELL_GCM_TEXTURE_X32_FLOAT: return DXGI_FORMAT_R32_FLOAT; case CELL_GCM_TEXTURE_X32_FLOAT: return DXGI_FORMAT_R32_FLOAT;

View File

@ -222,6 +222,9 @@ struct D3D12Traits
extraData.first->CreateGraphicsPipelineState(&graphicPipelineStateDesc, IID_PPV_ARGS(&std::get<0>(*result))); extraData.first->CreateGraphicsPipelineState(&graphicPipelineStateDesc, IID_PPV_ARGS(&std::get<0>(*result)));
std::get<1>(*result) = vertexProgramData.vertex_shader_inputs; std::get<1>(*result) = vertexProgramData.vertex_shader_inputs;
std::wstring name = L"PSO_" + std::to_wstring(vertexProgramData.id) + L"_" + std::to_wstring(fragmentProgramData.id);
std::get<0>(*result)->SetName(name.c_str());
return result; return result;
} }

View File

@ -77,7 +77,7 @@ void D3D12GSRender::clear_surface(u32 arg)
if (arg & 0x1 || arg & 0x2) if (arg & 0x1 || arg & 0x2)
{ {
CD3DX12_CPU_DESCRIPTOR_HANDLE handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().depth_stencil_descriptor_heap->GetCPUDescriptorHandleForHeapStart()) CD3DX12_CPU_DESCRIPTOR_HANDLE handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().depth_stencil_descriptor_heap->GetCPUDescriptorHandleForHeapStart())
.Offset(get_current_resource_storage().depth_stencil_descriptor_heap_index * g_descriptor_stride_rtv); .Offset((INT)get_current_resource_storage().depth_stencil_descriptor_heap_index * g_descriptor_stride_rtv);
m_rtts.bind_depth_stencil(m_device.Get(), m_surface.depth_format, handle); m_rtts.bind_depth_stencil(m_device.Get(), m_surface.depth_format, handle);
get_current_resource_storage().depth_stencil_descriptor_heap_index++; get_current_resource_storage().depth_stencil_descriptor_heap_index++;
@ -97,7 +97,7 @@ void D3D12GSRender::clear_surface(u32 arg)
if (arg & 0xF0) if (arg & 0xF0)
{ {
CD3DX12_CPU_DESCRIPTOR_HANDLE handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().render_targets_descriptors_heap->GetCPUDescriptorHandleForHeapStart()) CD3DX12_CPU_DESCRIPTOR_HANDLE handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().render_targets_descriptors_heap->GetCPUDescriptorHandleForHeapStart())
.Offset(get_current_resource_storage().render_targets_descriptors_heap_index * g_descriptor_stride_rtv); .Offset((INT)get_current_resource_storage().render_targets_descriptors_heap_index * g_descriptor_stride_rtv);
size_t rtt_index = m_rtts.bind_render_targets(m_device.Get(), m_surface.color_format, handle); size_t rtt_index = m_rtts.bind_render_targets(m_device.Get(), m_surface.color_format, handle);
get_current_resource_storage().render_targets_descriptors_heap_index += rtt_index; get_current_resource_storage().render_targets_descriptors_heap_index += rtt_index;
for (unsigned i = 0; i < rtt_index; i++) for (unsigned i = 0; i < rtt_index; i++)
@ -251,11 +251,11 @@ size_t render_targets::bind_depth_stencil(ID3D12Device *device, u32 depth_format
void D3D12GSRender::set_rtt_and_ds(ID3D12GraphicsCommandList *command_list) void D3D12GSRender::set_rtt_and_ds(ID3D12GraphicsCommandList *command_list)
{ {
CD3DX12_CPU_DESCRIPTOR_HANDLE handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().render_targets_descriptors_heap->GetCPUDescriptorHandleForHeapStart()) CD3DX12_CPU_DESCRIPTOR_HANDLE handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().render_targets_descriptors_heap->GetCPUDescriptorHandleForHeapStart())
.Offset(get_current_resource_storage().render_targets_descriptors_heap_index * g_descriptor_stride_rtv); .Offset((INT)get_current_resource_storage().render_targets_descriptors_heap_index * g_descriptor_stride_rtv);
size_t num_rtt = m_rtts.bind_render_targets(m_device.Get(), m_surface.color_format, handle); size_t num_rtt = m_rtts.bind_render_targets(m_device.Get(), m_surface.color_format, handle);
get_current_resource_storage().render_targets_descriptors_heap_index += num_rtt; get_current_resource_storage().render_targets_descriptors_heap_index += num_rtt;
CD3DX12_CPU_DESCRIPTOR_HANDLE depth_stencil_handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().depth_stencil_descriptor_heap->GetCPUDescriptorHandleForHeapStart()) CD3DX12_CPU_DESCRIPTOR_HANDLE depth_stencil_handle = CD3DX12_CPU_DESCRIPTOR_HANDLE(get_current_resource_storage().depth_stencil_descriptor_heap->GetCPUDescriptorHandleForHeapStart())
.Offset(get_current_resource_storage().depth_stencil_descriptor_heap_index * g_descriptor_stride_rtv); .Offset((INT)get_current_resource_storage().depth_stencil_descriptor_heap_index * g_descriptor_stride_rtv);
size_t num_ds = m_rtts.bind_depth_stencil(m_device.Get(), m_surface.depth_format, depth_stencil_handle); size_t num_ds = m_rtts.bind_depth_stencil(m_device.Get(), m_surface.depth_format, depth_stencil_handle);
get_current_resource_storage().depth_stencil_descriptor_heap_index += num_ds; get_current_resource_storage().depth_stencil_descriptor_heap_index += num_ds;
command_list->OMSetRenderTargets((UINT)num_rtt, num_rtt > 0 ? &handle : nullptr, !!num_rtt, command_list->OMSetRenderTargets((UINT)num_rtt, num_rtt > 0 ? &handle : nullptr, !!num_rtt,
@ -299,6 +299,8 @@ ID3D12Resource *render_targets::bind_address_as_render_targets(ID3D12Device *dev
IID_PPV_ARGS(rtt.GetAddressOf()) IID_PPV_ARGS(rtt.GetAddressOf())
); );
render_targets_storage[address] = rtt; render_targets_storage[address] = rtt;
std::wstring name = L"rtt_@" + std::to_wstring(address);
rtt->SetName(name.c_str());
return rtt.Get(); return rtt.Get();
} }
@ -339,6 +341,8 @@ ID3D12Resource * render_targets::bind_address_as_depth_stencil(ID3D12Device * de
IID_PPV_ARGS(new_depth_stencil.GetAddressOf()) IID_PPV_ARGS(new_depth_stencil.GetAddressOf())
); );
depth_stencil_storage[address] = new_depth_stencil; depth_stencil_storage[address] = new_depth_stencil;
std::wstring name = L"ds_@" + std::to_wstring(address);
new_depth_stencil->SetName(name.c_str());
return new_depth_stencil.Get(); return new_depth_stencil.Get();
} }
@ -640,8 +644,8 @@ void D3D12GSRender::copy_render_targets_to_memory(void *buffer, u8 rtt)
void D3D12GSRender::copy_depth_buffer_to_memory(void *buffer) void D3D12GSRender::copy_depth_buffer_to_memory(void *buffer)
{ {
int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; unsigned clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16;
int clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; unsigned clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16;
size_t row_pitch = align(clip_w * 4, 256); size_t row_pitch = align(clip_w * 4, 256);
@ -678,8 +682,8 @@ void D3D12GSRender::copy_depth_buffer_to_memory(void *buffer)
void D3D12GSRender::copy_stencil_buffer_to_memory(void *buffer) void D3D12GSRender::copy_stencil_buffer_to_memory(void *buffer)
{ {
int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; unsigned clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16;
int clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; unsigned clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16;
size_t row_pitch = align(clip_w * 4, 256); size_t row_pitch = align(clip_w * 4, 256);

View File

@ -53,6 +53,7 @@ ComPtr<ID3D12Resource> upload_single_texture(
{ {
size_t w = texture.width(), h = texture.height(); size_t w = texture.width(), h = texture.height();
size_t depth = texture.depth(); size_t depth = texture.depth();
if (depth == 0) depth = 1;
if (texture.cubemap()) depth *= 6; if (texture.cubemap()) depth *= 6;
const u8 format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); const u8 format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
@ -72,7 +73,7 @@ ComPtr<ID3D12Resource> upload_single_texture(
CHECK_HRESULT(device->CreateCommittedResource( CHECK_HRESULT(device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT), &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
D3D12_HEAP_FLAG_NONE, D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Tex2D(dxgi_format, (UINT)w, (UINT)h, depth, texture.mipmap()), &CD3DX12_RESOURCE_DESC::Tex2D(dxgi_format, (UINT)w, (UINT)h, (UINT)depth, texture.mipmap()),
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_DEST,
nullptr, nullptr,
IID_PPV_ARGS(result.GetAddressOf()) IID_PPV_ARGS(result.GetAddressOf())
@ -200,6 +201,8 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_
if (cached_texture != nullptr) if (cached_texture != nullptr)
get_current_resource_storage().dirty_textures.push_back(m_texture_cache.remove_from_cache(texaddr)); get_current_resource_storage().dirty_textures.push_back(m_texture_cache.remove_from_cache(texaddr));
ComPtr<ID3D12Resource> tex = upload_single_texture(textures[i], m_device.Get(), command_list, m_texture_upload_data); ComPtr<ID3D12Resource> tex = upload_single_texture(textures[i], m_device.Get(), command_list, m_texture_upload_data);
std::wstring name = L"texture_@" + std::to_wstring(texaddr);
tex->SetName(name.c_str());
vram_texture = tex.Get(); vram_texture = tex.Get();
m_texture_cache.store_and_protect_data(texaddr, texaddr, get_texture_size(textures[i]), format, w, h, textures[i].mipmap(), tex); m_texture_cache.store_and_protect_data(texaddr, texaddr, get_texture_size(textures[i]), format, w, h, textures[i].mipmap(), tex);
} }