瀏覽代碼

added map pitch

Nicolas Cannasse 8 年之前
父節點
當前提交
6e668ac0c5
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 4 2
      libs/directx/directx.cpp
  2. 1 1
      libs/directx/dx/Resource.hx

+ 4 - 2
libs/directx/directx.cpp

@@ -183,10 +183,12 @@ HL_PRIM void HL_NAME(update_subresource)( dx_resource *r, int index, dx_struct<D
 	driver->context->UpdateSubresource(r, index, box ? &box->value : NULL, data, srcRowPitch, srcDstPitch);
 }
 
-HL_PRIM void *HL_NAME(map)( dx_resource *r, int subRes, int type, bool waitGpu ) {
+HL_PRIM void *HL_NAME(map)( dx_resource *r, int subRes, int type, bool waitGpu, int *pitch ) {
 	D3D11_MAPPED_SUBRESOURCE map;
 	if( driver->context->Map(r,subRes,(D3D11_MAP)type,waitGpu?0:D3D11_MAP_FLAG_DO_NOT_WAIT,&map) != S_OK )
 		DXERR();
+	if( pitch )
+		*pitch = map.RowPitch;
 	return map.pData;
 }
 
@@ -389,7 +391,7 @@ DEFINE_PRIM(_VOID, present, _I32 _I32);
 DEFINE_PRIM(_BYTES, get_device_name, _NO_ARG);
 DEFINE_PRIM(_F64, get_supported_version, _NO_ARG);
 DEFINE_PRIM(_RESOURCE, create_buffer, _I32 _I32 _I32 _I32 _I32 _I32 _BYTES);
-DEFINE_PRIM(_BYTES, map, _RESOURCE _I32 _I32 _BOOL);
+DEFINE_PRIM(_BYTES, map, _RESOURCE _I32 _I32 _BOOL _REF(_I32));
 DEFINE_PRIM(_VOID, unmap, _RESOURCE _I32);
 DEFINE_PRIM(_VOID, copy_resource, _RESOURCE _RESOURCE);
 DEFINE_PRIM(_BYTES, compile_shader, _BYTES _I32 _BYTES _BYTES _BYTES _I32 _REF(_BOOL) _REF(_I32));

+ 1 - 1
libs/directx/dx/Resource.hx

@@ -25,7 +25,7 @@ class ResourceBox {
 abstract Resource(hl.Abstract<"dx_resource">) {
 
 	@:hlNative("directx", "map")
-	public function map( subResource : Int, type : MapType, waitGpu : Bool ) : hl.Bytes {
+	public function map( subResource : Int, type : MapType, waitGpu : Bool, pitch : hl.Ref<Int> ) : hl.Bytes {
 		return null;
 	}