Browse Source

[DX12] Added getConstant to DX12 wrapper

TothBenoit 9 months ago
parent
commit
4b2e7e87d3
2 changed files with 23 additions and 2 deletions
  1. 10 1
      libs/directx/dx/Dx12.hx
  2. 13 1
      libs/directx/dx12.cpp

+ 10 - 1
libs/directx/dx/Dx12.hx

@@ -8,6 +8,12 @@ enum DriverInitFlag {
 	DEBUG;
 }
 
+enum abstract Constant(Int) to Int {
+	public var TEXTURE_DATA_PITCH_ALIGNMENT;
+	public var TEXTURE_DATA_PLACEMENT_ALIGNMENT;
+	public var DESCRIPTOR_RANGE_OFFSET_APPEND;
+}
+
 enum abstract CommandListType(Int) {
 	public var DIRECT = 0;
 	public var BUNDLE = 1;
@@ -1624,6 +1630,10 @@ class Dx12 {
 	public static function resume() {
 	}
 
+	public static function getConstant( index : Int ) : Int {
+		return 0;
+	}
+
 	public static function getDeviceName() {
 		return @:privateAccess String.fromUCS2(dxGetDeviceName());
 	}
@@ -1657,5 +1667,4 @@ class Dx12 {
 	static function dxCreate( win : hl.Abstract<"dx_window">, flags : DriverInitFlags, deviceName : hl.Bytes ) : DriverInstance {
 		return null;
 	}
-
 }

+ 13 - 1
libs/directx/dx12.cpp

@@ -28,6 +28,12 @@
 #define DXERR(cmd)	{ HRESULT __ret = cmd; if( __ret == E_OUTOFMEMORY ) return NULL; if( __ret != S_OK ) ReportDxError(__ret,__LINE__); }
 #define CHKERR(cmd) { HRESULT __ret = cmd; if( FAILED(__ret) ) ReportDxError(__ret,__LINE__); }
 
+static int gs_constants[] = {
+	D3D12_TEXTURE_DATA_PITCH_ALIGNMENT,
+	D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT,
+	D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND
+};
+
 typedef struct {
 	HWND wnd;
 	ID3D12CommandQueue *commandQueue;
@@ -1003,4 +1009,10 @@ DEFINE_PRIM(_VOID, command_list_set_compute_root_unordered_access_view, _RES _I3
 DEFINE_PRIM(_VOID, command_list_dispatch, _RES _I32 _I32 _I32);
 
 //command_list_clear_unordered_access_view_float,
-//command_list_clear_unordered_access_view_uint,
+//command_list_clear_unordered_access_view_uint,
+
+HL_PRIM int HL_NAME(get_constant)(int index) {
+	return gs_constants[index];
+}
+
+DEFINE_PRIM(_I32, get_constant, _I32);