2
0
Nicolas Cannasse 3 жил өмнө
parent
commit
4e45de7ddd

+ 19 - 6
libs/directx/dx/Dx12.hx

@@ -23,6 +23,10 @@ typedef DriverInitFlags = haxe.EnumFlags<DriverInitFlag>;
 @:hlNative("dx12","resource_")
 abstract Resource(hl.Abstract<"dx_resource">) {
 	public function release() {}
+	public inline function setName( name : String ) {
+		set_name(@:privateAccess name.bytes);
+	}
+	function set_name( name : hl.Bytes ) {}
 }
 
 @:struct class Range {
@@ -32,7 +36,7 @@ abstract Resource(hl.Abstract<"dx_resource">) {
 	}
 }
 
-@:hlNative("dx12","resource_") @:forward(release)
+@:hlNative("dx12","resource_") @:forward(release, setName)
 abstract GpuResource(Resource) {
 	@:hlNative("dx12","resource_get_gpu_virtual_address")
 	public function getGpuVirtualAddress() : Int64 { return 0; }
@@ -139,17 +143,23 @@ enum abstract TextureCopyType(Int) {
 	}
 }
 
+@:struct class PlacedSubresourceFootprint {
+	public var offset : Int64;
+	@:packed public var footprint(default,null) : SubresourceFootprint;
+	public function new() {
+	}
+}
+
 @:struct class TextureCopyLocation {
 	public var res : GpuResource;
 	public var type : TextureCopyType;
 	var __unionPadding : Int;
 
 	public var subResourceIndex(get,set) : Int;
-	inline function get_subResourceIndex() : Int return offset.low & 0xFF;
-	inline function set_subResourceIndex(v: Int) { offset = v; return v; }
+	inline function get_subResourceIndex() : Int return placedFootprint.offset.low & 0xFF;
+	inline function set_subResourceIndex(v: Int) { placedFootprint.offset = v; return v; }
 
-	public var offset : Int64;
-	@:packed public var footprint(default,null) : SubresourceFootprint;
+	@:packed public var placedFootprint(default,null) : PlacedSubresourceFootprint;
 	public function new() {
 	}
 }
@@ -279,7 +289,7 @@ abstract ShaderCompiler(hl.Abstract<"dx_compiler">) {
 }
 
 @:hlNative("dx12","descriptor_heap_")
-abstract DescriptorHeap(Resource) {
+abstract DescriptorHeap(Resource) to Resource {
 	public function new(desc) {
 		this = create(desc);
 	}
@@ -1410,6 +1420,9 @@ class Dx12 {
 	public static function createShaderResourceView( resource : Resource, desc : ShaderResourceViewDesc, target : Address ) {
 	}
 
+	public static function getCopyableFootprints( srcDesc : ResourceDesc, firstSubResource : Int, numSubResources : Int, baseOffset : Int64, layouts : PlacedSubresourceFootprint, numRows : hl.BytesAccess<Int>, rowSizeInBytes : hl.BytesAccess<Int64>, totalBytes : hl.BytesAccess<Int64> ) : Void {
+	}
+
 	public static function createSampler( desc : SamplerDesc, target : Address ) {
 	}
 

+ 10 - 1
libs/directx/dx12.cpp

@@ -358,6 +358,10 @@ void HL_NAME(resource_release)( IUnknown *res ) {
 	res->Release();
 }
 
+void HL_NAME(resource_set_name)( ID3D12Resource *res, vbyte *name ) {
+	res->SetName((LPCWSTR)name);
+}
+
 void *HL_NAME(resource_map)( ID3D12Resource *res, int subres, D3D12_RANGE *range ) {
 	void *data = NULL;
 	DXERR(res->Map(subres, range, &data));
@@ -379,6 +383,10 @@ bool HL_NAME(update_sub_resource)( ID3D12GraphicsCommandList *cmd, ID3D12Resourc
 	return UpdateSubresources(cmd,res,tmp,(UINT64)tmpOffs,(UINT)first,(UINT)count,data) != 0;
 }
 
+void HL_NAME(get_copyable_footprints)( D3D12_RESOURCE_DESC *desc, int first, int count, int64 offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, int *numRows, int64 *rowSizes, int64 *totalBytes ) {
+    static_driver->device->GetCopyableFootprints(desc, first, count, offset, layouts, (UINT*)numRows, (UINT64*)rowSizes, (UINT64*)totalBytes);
+}
+
 DEFINE_PRIM(_VOID, create_render_target_view, _RES _STRUCT _I64);
 DEFINE_PRIM(_VOID, create_depth_stencil_view, _RES _STRUCT _I64);
 DEFINE_PRIM(_VOID, create_shader_resource_view, _RES _STRUCT _I64);
@@ -387,12 +395,13 @@ DEFINE_PRIM(_VOID, create_sampler, _STRUCT _I64);
 DEFINE_PRIM(_RES, create_committed_resource, _STRUCT _I32 _STRUCT _I32 _STRUCT);
 DEFINE_PRIM(_RES, get_back_buffer, _I32);
 DEFINE_PRIM(_VOID, resource_release, _RES);
+DEFINE_PRIM(_VOID, resource_set_name, _RES _BYTES);
 DEFINE_PRIM(_I64, resource_get_gpu_virtual_address, _RES);
 DEFINE_PRIM(_BYTES, resource_map, _RES _I32 _STRUCT);
 DEFINE_PRIM(_VOID, resource_unmap, _RES _I32 _STRUCT);
 DEFINE_PRIM(_I64, get_required_intermediate_size, _RES _I32 _I32);
 DEFINE_PRIM(_BOOL, update_sub_resource, _RES _RES _RES _I64 _I32 _I32 _STRUCT);
-
+DEFINE_PRIM(_VOID, get_copyable_footprints, _STRUCT _I32 _I32 _I64 _STRUCT _BYTES _BYTES _BYTES);
 
 // ---- SHADERS