mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-24 04:18:23 -05:00
Add D3D12 Agility SDK & implement triangle fans.
This commit is contained in:
@@ -29,6 +29,11 @@
|
||||
#define D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
__declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_SDK_VERSION;
|
||||
__declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\";
|
||||
}
|
||||
|
||||
namespace RT64 {
|
||||
static const uint32_t ShaderDescriptorHeapSize = 65536;
|
||||
static const uint32_t SamplerDescriptorHeapSize = 1024;
|
||||
@@ -473,7 +478,9 @@ namespace RT64 {
|
||||
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
|
||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
|
||||
case RenderPrimitiveTopology::TRIANGLE_FAN:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLEFAN;
|
||||
default:
|
||||
assert(false && "Unknown primitive topology.");
|
||||
return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
||||
@@ -489,6 +496,7 @@ namespace RT64 {
|
||||
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
|
||||
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
||||
case RenderPrimitiveTopology::TRIANGLE_STRIP:
|
||||
case RenderPrimitiveTopology::TRIANGLE_FAN:
|
||||
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||
default:
|
||||
assert(false && "Unknown primitive topology type.");
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <directx/d3d12.h>
|
||||
#include <dxgi1_4.h>
|
||||
|
||||
#include "D3D12MemAlloc.h"
|
||||
|
||||
@@ -168,7 +168,8 @@ namespace RT64 {
|
||||
LINE_LIST,
|
||||
LINE_STRIP,
|
||||
TRIANGLE_LIST,
|
||||
TRIANGLE_STRIP
|
||||
TRIANGLE_STRIP,
|
||||
TRIANGLE_FAN
|
||||
};
|
||||
|
||||
enum class RenderSRVType {
|
||||
|
||||
@@ -332,7 +332,9 @@ namespace RT64 {
|
||||
case RenderPrimitiveTopology::TRIANGLE_LIST:
|
||||
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
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:
|
||||
assert(false && "Unknown primitive topology type.");
|
||||
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.spirv.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
||||
}
|
||||
|
||||
namespace RT64
|
||||
{
|
||||
extern std::unique_ptr<RenderInterface> CreateD3D12Interface();
|
||||
@@ -1715,7 +1721,9 @@ static RenderPrimitiveTopology ConvertPrimitiveType(uint32_t primitiveType)
|
||||
case D3DPT_QUADLIST:
|
||||
return RenderPrimitiveTopology::TRIANGLE_LIST;
|
||||
case D3DPT_TRIANGLESTRIP:
|
||||
return RenderPrimitiveTopology::TRIANGLE_STRIP;
|
||||
return RenderPrimitiveTopology::TRIANGLE_STRIP;
|
||||
case D3DPT_TRIANGLEFAN:
|
||||
return RenderPrimitiveTopology::TRIANGLE_FAN;
|
||||
default:
|
||||
assert(false && "Unknown primitive type");
|
||||
return RenderPrimitiveTopology::UNKNOWN;
|
||||
@@ -1727,13 +1735,6 @@ static void SetPrimitiveType(uint32_t 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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (TemporarySkipRendering(primitiveType))
|
||||
return;
|
||||
|
||||
SetPrimitiveType(primitiveType);
|
||||
|
||||
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)
|
||||
{
|
||||
if (TemporarySkipRendering(primitiveType))
|
||||
return;
|
||||
|
||||
CheckInstancing();
|
||||
SetPrimitiveType(primitiveType);
|
||||
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)
|
||||
{
|
||||
if (TemporarySkipRendering(primitiveType))
|
||||
return;
|
||||
|
||||
CheckInstancing();
|
||||
SetPrimitiveType(primitiveType);
|
||||
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.vertexStrides[0], uint8_t(vertexStreamZeroStride));
|
||||
|
||||
Reference in New Issue
Block a user