mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
Add D3D12 Agility SDK & implement triangle fans.
This commit is contained in:
parent
66c20e73c9
commit
02964750ad
8 changed files with 39 additions and 23 deletions
|
|
@ -94,6 +94,8 @@ endif()
|
||||||
|
|
||||||
set_target_properties(UnleashedRecomp PROPERTIES OUTPUT_NAME ${TARGET_NAME})
|
set_target_properties(UnleashedRecomp PROPERTIES OUTPUT_NAME ${TARGET_NAME})
|
||||||
|
|
||||||
|
find_package(directx-headers CONFIG REQUIRED)
|
||||||
|
find_package(directx12-agility CONFIG REQUIRED)
|
||||||
find_package(d3d12-memory-allocator CONFIG REQUIRED)
|
find_package(d3d12-memory-allocator CONFIG REQUIRED)
|
||||||
find_package(SDL2 CONFIG REQUIRED)
|
find_package(SDL2 CONFIG REQUIRED)
|
||||||
find_package(unordered_dense CONFIG REQUIRED)
|
find_package(unordered_dense CONFIG REQUIRED)
|
||||||
|
|
@ -106,9 +108,18 @@ pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus)
|
||||||
find_package(directx-dxc REQUIRED)
|
find_package(directx-dxc REQUIRED)
|
||||||
find_package(zstd CONFIG REQUIRED)
|
find_package(zstd CONFIG REQUIRED)
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/D3D12)
|
||||||
|
add_custom_command(TARGET UnleashedRecomp POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Core,IMPORTED_LOCATION_RELEASE> ${CMAKE_CURRENT_BINARY_DIR}/D3D12
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Layers,IMPORTED_LOCATION_DEBUG> ${CMAKE_CURRENT_BINARY_DIR}/D3D12
|
||||||
|
COMMAND_EXPAND_LISTS
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(UnleashedRecomp PRIVATE
|
target_link_libraries(UnleashedRecomp PRIVATE
|
||||||
|
Microsoft::DirectX-Headers
|
||||||
|
Microsoft::DirectX-Guids
|
||||||
|
Microsoft::DirectX12-Agility
|
||||||
comctl32
|
comctl32
|
||||||
d3d12
|
|
||||||
dxgi
|
dxgi
|
||||||
Vulkan::Headers
|
Vulkan::Headers
|
||||||
volk::volk
|
volk::volk
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@
|
||||||
#define D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)
|
#define D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
__declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_SDK_VERSION;
|
||||||
|
__declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\";
|
||||||
|
}
|
||||||
|
|
||||||
namespace RT64 {
|
namespace RT64 {
|
||||||
static const uint32_t ShaderDescriptorHeapSize = 65536;
|
static const uint32_t ShaderDescriptorHeapSize = 65536;
|
||||||
static const uint32_t SamplerDescriptorHeapSize = 1024;
|
static const uint32_t SamplerDescriptorHeapSize = 1024;
|
||||||
|
|
@ -473,7 +478,9 @@ namespace RT64 {
|
||||||
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
||||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||||
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
||||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
|
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
|
||||||
|
case RenderPrimitiveTopology::TRIANGLE_FAN:
|
||||||
|
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLEFAN;
|
||||||
default:
|
default:
|
||||||
assert(false && "Unknown primitive topology.");
|
assert(false && "Unknown primitive topology.");
|
||||||
return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
||||||
|
|
@ -489,6 +496,7 @@ namespace RT64 {
|
||||||
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
|
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
|
||||||
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
||||||
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
||||||
|
case RenderPrimitiveTopology::TRIANGLE_FAN:
|
||||||
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||||
default:
|
default:
|
||||||
assert(false && "Unknown primitive topology type.");
|
assert(false && "Unknown primitive topology type.");
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <d3d12.h>
|
#include <directx/d3d12.h>
|
||||||
#include <dxgi1_4.h>
|
#include <dxgi1_4.h>
|
||||||
|
|
||||||
#include "D3D12MemAlloc.h"
|
#include "D3D12MemAlloc.h"
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,8 @@ namespace RT64 {
|
||||||
LINE_LIST,
|
LINE_LIST,
|
||||||
LINE_STRIP,
|
LINE_STRIP,
|
||||||
TRIANGLE_LIST,
|
TRIANGLE_LIST,
|
||||||
TRIANGLE_STRIP
|
TRIANGLE_STRIP,
|
||||||
|
TRIANGLE_FAN
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class RenderSRVType {
|
enum class RenderSRVType {
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,9 @@ namespace RT64 {
|
||||||
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
||||||
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||||
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
||||||
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
|
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
|
||||||
|
case RenderPrimitiveTopology::TRIANGLE_FAN:
|
||||||
|
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN;
|
||||||
default:
|
default:
|
||||||
assert(false && "Unknown primitive topology type.");
|
assert(false && "Unknown primitive topology type.");
|
||||||
return VK_PRIMITIVE_TOPOLOGY_MAX_ENUM;
|
return VK_PRIMITIVE_TOPOLOGY_MAX_ENUM;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@
|
||||||
#include "shader/resolve_msaa_depth_8x.hlsl.dxil.h"
|
#include "shader/resolve_msaa_depth_8x.hlsl.dxil.h"
|
||||||
#include "shader/resolve_msaa_depth_8x.hlsl.spirv.h"
|
#include "shader/resolve_msaa_depth_8x.hlsl.spirv.h"
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||||
|
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
||||||
|
}
|
||||||
|
|
||||||
namespace RT64
|
namespace RT64
|
||||||
{
|
{
|
||||||
extern std::unique_ptr<RenderInterface> CreateD3D12Interface();
|
extern std::unique_ptr<RenderInterface> CreateD3D12Interface();
|
||||||
|
|
@ -1715,7 +1721,9 @@ static RenderPrimitiveTopology ConvertPrimitiveType(uint32_t primitiveType)
|
||||||
case D3DPT_QUADLIST:
|
case D3DPT_QUADLIST:
|
||||||
return RenderPrimitiveTopology::TRIANGLE_LIST;
|
return RenderPrimitiveTopology::TRIANGLE_LIST;
|
||||||
case D3DPT_TRIANGLESTRIP:
|
case D3DPT_TRIANGLESTRIP:
|
||||||
return RenderPrimitiveTopology::TRIANGLE_STRIP;
|
return RenderPrimitiveTopology::TRIANGLE_STRIP;
|
||||||
|
case D3DPT_TRIANGLEFAN:
|
||||||
|
return RenderPrimitiveTopology::TRIANGLE_FAN;
|
||||||
default:
|
default:
|
||||||
assert(false && "Unknown primitive type");
|
assert(false && "Unknown primitive type");
|
||||||
return RenderPrimitiveTopology::UNKNOWN;
|
return RenderPrimitiveTopology::UNKNOWN;
|
||||||
|
|
@ -1727,13 +1735,6 @@ static void SetPrimitiveType(uint32_t primitiveType)
|
||||||
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.primitiveTopology, ConvertPrimitiveType(primitiveType));
|
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.primitiveTopology, ConvertPrimitiveType(primitiveType));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool TemporarySkipRendering(uint32_t primitiveType)
|
|
||||||
{
|
|
||||||
return primitiveType == D3DPT_TRIANGLEFAN ||
|
|
||||||
g_pipelineState.vertexShader == nullptr ||
|
|
||||||
g_pipelineState.vertexShader->shader == nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t CheckInstancing()
|
static uint32_t CheckInstancing()
|
||||||
{
|
{
|
||||||
uint32_t indexCount = 0;
|
uint32_t indexCount = 0;
|
||||||
|
|
@ -1750,9 +1751,6 @@ static uint32_t CheckInstancing()
|
||||||
|
|
||||||
static void DrawPrimitive(GuestDevice* device, uint32_t primitiveType, uint32_t startVertex, uint32_t primitiveCount)
|
static void DrawPrimitive(GuestDevice* device, uint32_t primitiveType, uint32_t startVertex, uint32_t primitiveCount)
|
||||||
{
|
{
|
||||||
if (TemporarySkipRendering(primitiveType))
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetPrimitiveType(primitiveType);
|
SetPrimitiveType(primitiveType);
|
||||||
|
|
||||||
uint32_t indexCount = CheckInstancing();
|
uint32_t indexCount = CheckInstancing();
|
||||||
|
|
@ -1777,9 +1775,6 @@ static void DrawPrimitive(GuestDevice* device, uint32_t primitiveType, uint32_t
|
||||||
|
|
||||||
static void DrawIndexedPrimitive(GuestDevice* device, uint32_t primitiveType, int32_t baseVertexIndex, uint32_t startIndex, uint32_t primCount)
|
static void DrawIndexedPrimitive(GuestDevice* device, uint32_t primitiveType, int32_t baseVertexIndex, uint32_t startIndex, uint32_t primCount)
|
||||||
{
|
{
|
||||||
if (TemporarySkipRendering(primitiveType))
|
|
||||||
return;
|
|
||||||
|
|
||||||
CheckInstancing();
|
CheckInstancing();
|
||||||
SetPrimitiveType(primitiveType);
|
SetPrimitiveType(primitiveType);
|
||||||
FlushRenderState(device);
|
FlushRenderState(device);
|
||||||
|
|
@ -1788,9 +1783,6 @@ static void DrawIndexedPrimitive(GuestDevice* device, uint32_t primitiveType, in
|
||||||
|
|
||||||
static void DrawPrimitiveUP(GuestDevice* device, uint32_t primitiveType, uint32_t primitiveCount, void* vertexStreamZeroData, uint32_t vertexStreamZeroStride)
|
static void DrawPrimitiveUP(GuestDevice* device, uint32_t primitiveType, uint32_t primitiveCount, void* vertexStreamZeroData, uint32_t vertexStreamZeroStride)
|
||||||
{
|
{
|
||||||
if (TemporarySkipRendering(primitiveType))
|
|
||||||
return;
|
|
||||||
|
|
||||||
CheckInstancing();
|
CheckInstancing();
|
||||||
SetPrimitiveType(primitiveType);
|
SetPrimitiveType(primitiveType);
|
||||||
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.vertexStrides[0], uint8_t(vertexStreamZeroStride));
|
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.vertexStrides[0], uint8_t(vertexStreamZeroStride));
|
||||||
|
|
|
||||||
2
thirdparty/ShaderRecomp
vendored
2
thirdparty/ShaderRecomp
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit b15214270923fa9d73dd59d5a27170acdcb8d689
|
Subproject commit 6477f65937e7d95717fd7d857ad9315015bfacf5
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
{
|
{
|
||||||
"builtin-baseline": "e63bd09dc0b7204467705c1c7c71d0e2a3f8860b",
|
"builtin-baseline": "e63bd09dc0b7204467705c1c7c71d0e2a3f8860b",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
"directx-headers",
|
||||||
|
"directx12-agility",
|
||||||
"d3d12-memory-allocator",
|
"d3d12-memory-allocator",
|
||||||
"directx-dxc",
|
"directx-dxc",
|
||||||
"sdl2",
|
"sdl2",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue