Hi Guys,
I have started to have a crack at partially wrapping DX11 into an 'inc' file.
At this stage I'll attempt to get as far as device creation etc and if successful move on from there.
So far I have the following;
; --------------------------------------------------------------------------------------------------
; d3d11.inc
; --------------------------------------------------------------------------------------------------
IFNDEF D3D11_INC
D3D11_INC equ <1>
DXGI_FORMAT_UNKNOWN equ 0
DXGI_FORMAT_R32G32B32A32_TYPELESS equ 1
DXGI_FORMAT_R32G32B32A32_FLOAT equ 2
DXGI_FORMAT_R32G32B32A32_UINT equ 3
DXGI_FORMAT_R32G32B32A32_SINT equ 4
DXGI_FORMAT_R32G32B32_TYPELESS equ 5
DXGI_FORMAT_R32G32B32_FLOAT equ 6
DXGI_FORMAT_R32G32B32_UINT equ 7
DXGI_FORMAT_R32G32B32_SINT equ 8
DXGI_FORMAT_R16G16B16A16_TYPELESS equ 9
DXGI_FORMAT_R16G16B16A16_FLOAT equ 10
DXGI_FORMAT_R16G16B16A16_UNORM equ 11
DXGI_FORMAT_R16G16B16A16_UINT equ 12
DXGI_FORMAT_R16G16B16A16_SNORM equ 13
DXGI_FORMAT_R16G16B16A16_SINT equ 14
DXGI_FORMAT_R32G32_TYPELESS equ 15
DXGI_FORMAT_R32G32_FLOAT equ 16
DXGI_FORMAT_R32G32_UINT equ 17
DXGI_FORMAT_R32G32_SINT equ 18
DXGI_FORMAT_R32G8X24_TYPELESS equ 19
DXGI_FORMAT_D32_FLOAT_S8X24_UINT equ 20
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS equ 21
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT equ 22
DXGI_FORMAT_R10G10B10A2_TYPELESS equ 23
DXGI_FORMAT_R10G10B10A2_UNORM equ 24
DXGI_FORMAT_R10G10B10A2_UINT equ 25
DXGI_FORMAT_R11G11B10_FLOAT equ 26
DXGI_FORMAT_R8G8B8A8_TYPELESS equ 27
DXGI_FORMAT_R8G8B8A8_UNORM equ 28
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB equ 29
DXGI_FORMAT_R8G8B8A8_UINT equ 30
DXGI_FORMAT_R8G8B8A8_SNORM equ 31
DXGI_FORMAT_R8G8B8A8_SINT equ 32
DXGI_FORMAT_R16G16_TYPELESS equ 33
DXGI_FORMAT_R16G16_FLOAT equ 34
DXGI_FORMAT_R16G16_UNORM equ 35
DXGI_FORMAT_R16G16_UINT equ 36
DXGI_FORMAT_R16G16_SNORM equ 37
DXGI_FORMAT_R16G16_SINT equ 38
DXGI_FORMAT_R32_TYPELESS equ 39
DXGI_FORMAT_D32_FLOAT equ 40
DXGI_FORMAT_R32_FLOAT equ 41
DXGI_FORMAT_R32_UINT equ 42
DXGI_FORMAT_R32_SINT equ 43
DXGI_FORMAT_R24G8_TYPELESS equ 44
DXGI_FORMAT_D24_UNORM_S8_UINT equ 45
DXGI_FORMAT_R24_UNORM_X8_TYPELESS equ 46
DXGI_FORMAT_X24_TYPELESS_G8_UINT equ 47
DXGI_FORMAT_R8G8_TYPELESS equ 48
DXGI_FORMAT_R8G8_UNORM equ 49
DXGI_FORMAT_R8G8_UINT equ 50
DXGI_FORMAT_R8G8_SNORM equ 51
DXGI_FORMAT_R8G8_SINT equ 52
DXGI_FORMAT_R16_TYPELESS equ 53
DXGI_FORMAT_R16_FLOAT equ 54
DXGI_FORMAT_D16_UNORM equ 55
DXGI_FORMAT_R16_UNORM equ 56
DXGI_FORMAT_R16_UINT equ 57
DXGI_FORMAT_R16_SNORM equ 58
DXGI_FORMAT_R16_SINT equ 59
DXGI_FORMAT_R8_TYPELESS equ 60
DXGI_FORMAT_R8_UNORM equ 61
DXGI_FORMAT_R8_UINT equ 62
DXGI_FORMAT_R8_SNORM equ 63
DXGI_FORMAT_R8_SINT equ 64
DXGI_FORMAT_A8_UNORM equ 65
DXGI_FORMAT_R1_UNORM equ 66
DXGI_FORMAT_R9G9B9E5_SHAREDEXP equ 67
DXGI_FORMAT_R8G8_B8G8_UNORM equ 68
DXGI_FORMAT_G8R8_G8B8_UNORM equ 69
DXGI_FORMAT_BC1_TYPELESS equ 70
DXGI_FORMAT_BC1_UNORM equ 71
DXGI_FORMAT_BC1_UNORM_SRGB equ 72
DXGI_FORMAT_BC2_TYPELESS equ 73
DXGI_FORMAT_BC2_UNORM equ 74
DXGI_FORMAT_BC2_UNORM_SRGB equ 75
DXGI_FORMAT_BC3_TYPELESS equ 76
DXGI_FORMAT_BC3_UNORM equ 77
DXGI_FORMAT_BC3_UNORM_SRGB equ 78
DXGI_FORMAT_BC4_TYPELESS equ 79
DXGI_FORMAT_BC4_UNORM equ 80
DXGI_FORMAT_BC4_SNORM equ 81
DXGI_FORMAT_BC5_TYPELESS equ 82
DXGI_FORMAT_BC5_UNORM equ 83
DXGI_FORMAT_BC5_SNORM equ 84
DXGI_FORMAT_B5G6R5_UNORM equ 85
DXGI_FORMAT_B5G5R5A1_UNORM equ 86
DXGI_FORMAT_B8G8R8A8_UNORM equ 87
DXGI_FORMAT_B8G8R8X8_UNORM equ 88
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM equ 89
DXGI_FORMAT_B8G8R8A8_TYPELESS equ 90
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB equ 91
DXGI_FORMAT_B8G8R8X8_TYPELESS equ 92
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB equ 93
DXGI_FORMAT_BC6H_TYPELESS equ 94
DXGI_FORMAT_BC6H_UF16 equ 95
DXGI_FORMAT_BC6H_SF16 equ 96
DXGI_FORMAT_BC7_TYPELESS equ 97
DXGI_FORMAT_BC7_UNORM equ 98
DXGI_FORMAT_BC7_UNORM_SRGB equ 99
DXGI_FORMAT_AYUV equ 100
DXGI_FORMAT_Y410 equ 101
DXGI_FORMAT_Y416 equ 102
DXGI_FORMAT_NV12 equ 103
DXGI_FORMAT_P010 equ 104
DXGI_FORMAT_P016 equ 105
DXGI_FORMAT_420_OPAQUE equ 106
DXGI_FORMAT_YUY2 equ 107
DXGI_FORMAT_Y210 equ 108
DXGI_FORMAT_Y216 equ 109
DXGI_FORMAT_NV11 equ 110
DXGI_FORMAT_AI44 equ 111
DXGI_FORMAT_IA44 equ 112
DXGI_FORMAT_P8 equ 113
DXGI_FORMAT_A8P8 equ 114
DXGI_FORMAT_B4G4R4A4_UNORM equ 115
DXGI_FORMAT_P208 equ 130
DXGI_FORMAT_V208 equ 131
DXGI_FORMAT_V408 equ 132
DXGI_FORMAT_FORCE_UINT equ 0xffffffff
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED equ 0
DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE equ 1
DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST equ 2
DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST equ 3
DXGI_MODE_SCALING_UNSPECIFIED equ 0
DXGI_MODE_SCALING_CENTERED equ 1
DXGI_MODE_SCALING_STRETCHED equ 2
DXGI_CPU_ACCESS_NONE equ 0
DXGI_CPU_ACCESS_DYNAMIC equ 1
DXGI_CPU_ACCESS_READ_WRITE equ 2
DXGI_CPU_ACCESS_SCRATCH equ 3
DXGI_CPU_ACCESS_FIELD equ 15
; ****** Hard code the rest later ******
;#define DXGI_USAGE_SHADER_INPUT ( 1L << (0 + 4) )
;#define DXGI_USAGE_RENDER_TARGET_OUTPUT ( 1L << (1 + 4) )
;#define DXGI_USAGE_BACK_BUFFER ( 1L << (2 + 4) )
;#define DXGI_USAGE_SHARED ( 1L << (3 + 4) )
;#define DXGI_USAGE_READ_ONLY ( 1L << (4 + 4) )
;#define DXGI_USAGE_DISCARD_ON_PRESENT ( 1L << (5 + 4) )
;#define DXGI_USAGE_UNORDERED_ACCESS ( 1L << (6 + 4) )
DXGI_SWAP_EFFECT_DISCARD equ 0
DXGI_SWAP_EFFECT_SEQUENTIAL equ 1
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL equ 3
DXGI_SWAP_EFFECT_FLIP_DISCARD equ 4
DXGI_RATIONAL STRUCT
Numerator DWORD ?
Denominator DWORD ?
DXGI_RATIONAL ENDS
DXGI_MODE_DESC STRUCT
UINT DWORD ?
UINT DWORD ?
DXGI_RATIONAL_ DXGI_RATIONAL <?>
DXGI_FORMAT DWORD ?
DXGI_MODE_SCANLINE_ORDER DWORD ?
DXGI_MODE_SCALING DWORD ?
DXGI_MODE_DESC ENDS
DXGI_SAMPLE_DESC STRUCT
Count DWORD ?
Quality DWORD ?
DXGI_SAMPLE_DESC ENDS
DXGI_SWAP_CHAIN_DESC STRUCT
DXGI_MODE_DESC_ DXGI_MODE_DESC <?>
DXGI_SAMPLE_DESC_ DXGI_SAMPLE_DESC <?>
DXGI_USAGE DWORD ?
UINT DWORD ?
HWND DWORD ?
BOOL DWORD ?
DXGI_SWAP_EFFECT DWORD ?
UINT DWORD ?
DXGI_SWAP_CHAIN_DESC ENDS
ELSE
echo ---------------------------------------
echo WARNING duplicate include file d3d11.inc
echo ---------------------------------------
ENDIF
This compiles fine when I add the include to my main project, but if I try to setup the swapchain description I get a few errors.
.data
sd DXGI_SWAP_CHAIN_DESC <?>
Quote
source.asm(38) : error A2181: initializer must be a string or single item
source.asm(38) : error A2138: invalid data initializer
source.asm(38) : error A2009: syntax error in expression
Am I going about this the right way?
Any advice would be hugely appreciated.
Just take away the question mark: sd DXGI_SWAP_CHAIN_DESC <>
DXGI_MODE_DESC STRUCT
UINT1 DWORD ?
UINT2 DWORD ?
DXGI_RATIONAL_ DXGI_RATIONAL <?>
etc - you cannot use UINT twice in the same struct. Besides, I would avoid names that resemble basic types.
Quote from: jj2007 on April 04, 2018, 06:41:35 PM
Just take away the question mark: sd DXGI_SWAP_CHAIN_DESC <>
DXGI_MODE_DESC STRUCT
UINT1 DWORD ?
UINT2 DWORD ?
DXGI_RATIONAL_ DXGI_RATIONAL <?>
Ah ok cool :)
Quote
etc - you cannot use UINT twice in the same struct. Besides, I would avoid names that resemble basic types.
Oops! I realise I have made a couple off errors in there that I need to clean up. I mixed up the types with the variable names when I was copying from MSDN - LOL.
Thanks again. I'll get back to you and let you know how it goes :)
Builds great now 8)
Posting code here so I don't re-invent the wheel once again in another two years time. :bgrin:
; --------------------------------------------------------------------------------------------------
; d3d11.inc
; --------------------------------------------------------------------------------------------------
IFNDEF D3D11_INC
D3D11_INC equ <1>
DXGI_FORMAT_UNKNOWN equ 0
DXGI_FORMAT_R32G32B32A32_TYPELESS equ 1
DXGI_FORMAT_R32G32B32A32_FLOAT equ 2
DXGI_FORMAT_R32G32B32A32_UINT equ 3
DXGI_FORMAT_R32G32B32A32_SINT equ 4
DXGI_FORMAT_R32G32B32_TYPELESS equ 5
DXGI_FORMAT_R32G32B32_FLOAT equ 6
DXGI_FORMAT_R32G32B32_UINT equ 7
DXGI_FORMAT_R32G32B32_SINT equ 8
DXGI_FORMAT_R16G16B16A16_TYPELESS equ 9
DXGI_FORMAT_R16G16B16A16_FLOAT equ 10
DXGI_FORMAT_R16G16B16A16_UNORM equ 11
DXGI_FORMAT_R16G16B16A16_UINT equ 12
DXGI_FORMAT_R16G16B16A16_SNORM equ 13
DXGI_FORMAT_R16G16B16A16_SINT equ 14
DXGI_FORMAT_R32G32_TYPELESS equ 15
DXGI_FORMAT_R32G32_FLOAT equ 16
DXGI_FORMAT_R32G32_UINT equ 17
DXGI_FORMAT_R32G32_SINT equ 18
DXGI_FORMAT_R32G8X24_TYPELESS equ 19
DXGI_FORMAT_D32_FLOAT_S8X24_UINT equ 20
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS equ 21
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT equ 22
DXGI_FORMAT_R10G10B10A2_TYPELESS equ 23
DXGI_FORMAT_R10G10B10A2_UNORM equ 24
DXGI_FORMAT_R10G10B10A2_UINT equ 25
DXGI_FORMAT_R11G11B10_FLOAT equ 26
DXGI_FORMAT_R8G8B8A8_TYPELESS equ 27
DXGI_FORMAT_R8G8B8A8_UNORM equ 28
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB equ 29
DXGI_FORMAT_R8G8B8A8_UINT equ 30
DXGI_FORMAT_R8G8B8A8_SNORM equ 31
DXGI_FORMAT_R8G8B8A8_SINT equ 32
DXGI_FORMAT_R16G16_TYPELESS equ 33
DXGI_FORMAT_R16G16_FLOAT equ 34
DXGI_FORMAT_R16G16_UNORM equ 35
DXGI_FORMAT_R16G16_UINT equ 36
DXGI_FORMAT_R16G16_SNORM equ 37
DXGI_FORMAT_R16G16_SINT equ 38
DXGI_FORMAT_R32_TYPELESS equ 39
DXGI_FORMAT_D32_FLOAT equ 40
DXGI_FORMAT_R32_FLOAT equ 41
DXGI_FORMAT_R32_UINT equ 42
DXGI_FORMAT_R32_SINT equ 43
DXGI_FORMAT_R24G8_TYPELESS equ 44
DXGI_FORMAT_D24_UNORM_S8_UINT equ 45
DXGI_FORMAT_R24_UNORM_X8_TYPELESS equ 46
DXGI_FORMAT_X24_TYPELESS_G8_UINT equ 47
DXGI_FORMAT_R8G8_TYPELESS equ 48
DXGI_FORMAT_R8G8_UNORM equ 49
DXGI_FORMAT_R8G8_UINT equ 50
DXGI_FORMAT_R8G8_SNORM equ 51
DXGI_FORMAT_R8G8_SINT equ 52
DXGI_FORMAT_R16_TYPELESS equ 53
DXGI_FORMAT_R16_FLOAT equ 54
DXGI_FORMAT_D16_UNORM equ 55
DXGI_FORMAT_R16_UNORM equ 56
DXGI_FORMAT_R16_UINT equ 57
DXGI_FORMAT_R16_SNORM equ 58
DXGI_FORMAT_R16_SINT equ 59
DXGI_FORMAT_R8_TYPELESS equ 60
DXGI_FORMAT_R8_UNORM equ 61
DXGI_FORMAT_R8_UINT equ 62
DXGI_FORMAT_R8_SNORM equ 63
DXGI_FORMAT_R8_SINT equ 64
DXGI_FORMAT_A8_UNORM equ 65
DXGI_FORMAT_R1_UNORM equ 66
DXGI_FORMAT_R9G9B9E5_SHAREDEXP equ 67
DXGI_FORMAT_R8G8_B8G8_UNORM equ 68
DXGI_FORMAT_G8R8_G8B8_UNORM equ 69
DXGI_FORMAT_BC1_TYPELESS equ 70
DXGI_FORMAT_BC1_UNORM equ 71
DXGI_FORMAT_BC1_UNORM_SRGB equ 72
DXGI_FORMAT_BC2_TYPELESS equ 73
DXGI_FORMAT_BC2_UNORM equ 74
DXGI_FORMAT_BC2_UNORM_SRGB equ 75
DXGI_FORMAT_BC3_TYPELESS equ 76
DXGI_FORMAT_BC3_UNORM equ 77
DXGI_FORMAT_BC3_UNORM_SRGB equ 78
DXGI_FORMAT_BC4_TYPELESS equ 79
DXGI_FORMAT_BC4_UNORM equ 80
DXGI_FORMAT_BC4_SNORM equ 81
DXGI_FORMAT_BC5_TYPELESS equ 82
DXGI_FORMAT_BC5_UNORM equ 83
DXGI_FORMAT_BC5_SNORM equ 84
DXGI_FORMAT_B5G6R5_UNORM equ 85
DXGI_FORMAT_B5G5R5A1_UNORM equ 86
DXGI_FORMAT_B8G8R8A8_UNORM equ 87
DXGI_FORMAT_B8G8R8X8_UNORM equ 88
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM equ 89
DXGI_FORMAT_B8G8R8A8_TYPELESS equ 90
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB equ 91
DXGI_FORMAT_B8G8R8X8_TYPELESS equ 92
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB equ 93
DXGI_FORMAT_BC6H_TYPELESS equ 94
DXGI_FORMAT_BC6H_UF16 equ 95
DXGI_FORMAT_BC6H_SF16 equ 96
DXGI_FORMAT_BC7_TYPELESS equ 97
DXGI_FORMAT_BC7_UNORM equ 98
DXGI_FORMAT_BC7_UNORM_SRGB equ 99
DXGI_FORMAT_AYUV equ 100
DXGI_FORMAT_Y410 equ 101
DXGI_FORMAT_Y416 equ 102
DXGI_FORMAT_NV12 equ 103
DXGI_FORMAT_P010 equ 104
DXGI_FORMAT_P016 equ 105
DXGI_FORMAT_420_OPAQUE equ 106
DXGI_FORMAT_YUY2 equ 107
DXGI_FORMAT_Y210 equ 108
DXGI_FORMAT_Y216 equ 109
DXGI_FORMAT_NV11 equ 110
DXGI_FORMAT_AI44 equ 111
DXGI_FORMAT_IA44 equ 112
DXGI_FORMAT_P8 equ 113
DXGI_FORMAT_A8P8 equ 114
DXGI_FORMAT_B4G4R4A4_UNORM equ 115
DXGI_FORMAT_P208 equ 130
DXGI_FORMAT_V208 equ 131
DXGI_FORMAT_V408 equ 132
DXGI_FORMAT_FORCE_UINT equ 0xffffffff
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED equ 0
DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE equ 1
DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST equ 2
DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST equ 3
DXGI_MODE_SCALING_UNSPECIFIED equ 0
DXGI_MODE_SCALING_CENTERED equ 1
DXGI_MODE_SCALING_STRETCHED equ 2
DXGI_CPU_ACCESS_NONE equ 0
DXGI_CPU_ACCESS_DYNAMIC equ 1
DXGI_CPU_ACCESS_READ_WRITE equ 2
DXGI_CPU_ACCESS_SCRATCH equ 3
DXGI_CPU_ACCESS_FIELD equ 15
DXGI_USAGE_SHADER_INPUT equ 16
DXGI_USAGE_RENDER_TARGET_OUTPUT equ 32
DXGI_USAGE_BACK_BUFFER equ 64
DXGI_USAGE_SHARED equ 128
DXGI_USAGE_READ_ONLY equ 256
DXGI_USAGE_DISCARD_ON_PRESENT equ 512
DXGI_USAGE_UNORDERED_ACCESS equ 1024
DXGI_SWAP_EFFECT_DISCARD equ 0
DXGI_SWAP_EFFECT_SEQUENTIAL equ 1
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL equ 3
DXGI_SWAP_EFFECT_FLIP_DISCARD equ 4
DXGI_RATIONAL STRUCT
Numerator DD ?
Denominator DD ?
DXGI_RATIONAL ENDS
DXGI_MODE_DESC STRUCT
WindowWidth DD ?
WindowHeight DD ?
RefreshRate DXGI_RATIONAL <?>
Format DD ?
ScanlineOrdering DD ?
Scaling DD ?
DXGI_MODE_DESC ENDS
DXGI_SAMPLE_DESC STRUCT
Count DD ?
Quality DD ?
DXGI_SAMPLE_DESC ENDS
DXGI_SWAP_CHAIN_DESC STRUCT
BufferDesc DXGI_MODE_DESC <?>
SampleDesc DXGI_SAMPLE_DESC <?>
BufferUsage DD ?
BufferCount DD ?
OutputWindow DD ?
Windowed DD ?
SwapEffect DD ?
Flags DD ?
DXGI_SWAP_CHAIN_DESC ENDS
ELSE
echo ---------------------------------------
echo WARNING duplicate include file d3d11.inc
echo ---------------------------------------
ENDIF
Will using the following initialise the struct instance to zero automatically?
sd DXGI_SWAP_CHAIN_DESC <>
Thanks again :biggrin:
Quote from: Lonewolff on April 04, 2018, 07:00:14 PMWill using the following initialise the struct instance to zero automatically?
YES. It's not documented well on MSDN, but the PE loader sets everything in the .data? section to zero; same for structures in .data? or .data
Since we are in the Campus:
Global variables in .data? have zero values at program start.In contrast, local variables like...
sometest proc
Local MyInteger, MyString, MyRect:RECT
...contain on entry to the proc whatever happened to be on the stack. If you want them to be zero, it's your job to zero them.
Awesome, thanks for the clarification :icon_cool:
I now have my first working function 8)
invoke D3D11CreateDeviceAndSwapChain, 0, D3D_DRIVER_TYPE_HARDWARE, 0, 0, 0, 0, D3D11_SDK_VERSION, addr scd, addr d3dSwapchain, addr d3dDevice, 0, addr d3dContext;
mov ddResult, eax
invoke itoa, ddResult, addr szBuffer, 10
invoke SetWindowText, hWnd, addr szBuffer
It is verified to be creating the Device and SwapChain by outputting the result to the title of the window.
Now for the tough questions :lol:
How do I set up my include file to get access to the COM functions?
If I can even just access d3dDevice->Release(), I can probably work from there and figure out much of what I need.
Again, the help is greatly appreciated :t
Hi Lonewolff,
I never touched DX11 but, you can look at my D3D9 sources I posted on the forum and see how to create an include file for DX11 and how to get access to the COM functions.
It's pretty much the same structure as in DX9.
You can find the include files in the Pixel Shader sources:
http://masm32.com/board/index.php?topic=6904.0
Here are some Direct3D9 examples I posted before with source code:
http://masm32.com/board/index.php?topic=5226.msg56100#msg56100
Quote from: Siekmanski on April 06, 2018, 09:52:15 AM
Hi Lonewolff,
I never touched DX11 but, you can look at my D3D9 sources I posted on the forum and see how to create an include file for DX11 and how to get access to the COM functions.
It's pretty much the same structure as in DX9.
You can find the include files in the Pixel Shader sources:
http://masm32.com/board/index.php?topic=6904.0
Here are some Direct3D9 examples I posted before with source code:
http://masm32.com/board/index.php?topic=5226.msg56100#msg56100
Hey dude, thanks for the reply.
I have been hard at it trying to wrap up ID3D11Device.
Could you shed an eye over this and see if it looks correct? Admittedly I have no experience with COM and ASM.
; Interface IID's
; {db6f6ddb-ac77-4e88-8253-819df9bbf140}
IID_ID3D11Device TEXTEQU <0db6f6ddbh,0ac77h,4e88h,{082h,053h,081h,09dh,0f9h,0bbh,0f1h,040h}>
D3D11CreateDevice PROTO :DWORD
_vtD3D11Device MACRO CastName:REQ
_vtIUnknown CastName
&CastName&_CheckCounter comethodX ?
&CastName&_CheckCounterInfo comethodX ?
&CastName&_CheckFeatureSupport comethodX ?
&CastName&_CheckFormatSupport comethodX ?
&CastName&_CheckMultisampleQualityLevels comethodX ?
&CastName&_CreateBlendState comethodX ?
&CastName&_CreateBuffer comethodX ?
&CastName&_CreateClassLinkage comethodX ?
&CastName&_CreateComputeShader comethodX ?
&CastName&_CreateCounter comethodX ?
&CastName&_CreateDeferredContext comethodX ?
&CastName&_CreateDepthStencilState comethodX ?
&CastName&_CreateDepthStencilView comethodX ?
&CastName&_CreateDomainShader comethodX ?
&CastName&_CreateGeometryShader comethodX ?
&CastName&_CreateGeometryShaderWithStreamOutput comethodX ?
&CastName&_CreateHullShader comethodX ?
&CastName&_CreateInputLayout comethodX ?
&CastName&_CreatePixelShader comethodX ?
&CastName&_CreatePredicate comethodX ?
&CastName&_CreateQuery comethodX ?
&CastName&_CreateRasterizerState comethodX ?
&CastName&_CreateRenderTargetView comethodX ?
&CastName&_CreateSamplerState comethodX ?
&CastName&_CreateShaderResourceView comethodX ?
&CastName&_CreateTexture1D comethodX ?
&CastName&_CreateTexture2D comethodX ?
&CastName&_CreateTexture3D comethodX ?
&CastName&_CreateUnorderedAccessView comethodX ?
&CastName&_CreateVertexShader comethodX ?
&CastName&_GetCreationFlags comethodX ?
&CastName&_GetDeviceRemovedReason comethodX ?
&CastName&_GetExceptionMode comethodX ?
&CastName&_GetFeatureLevel comethodX ?
&CastName&_GetImmediateContext comethodX ?
&CastName&_GetPrivateData comethodX ?
&CastName&_OpenSharedResource comethodX ?
&CastName&_SetExceptionMode comethodX ?
&CastName&_SetPrivateData comethodX ?
&CastName&_SetPrivateDataInterface comethodX ?
ENDM
IID_ID3D11Device STRUCT
_vtIDirect3D9 IDirect3D9
IID_ID3D11Device END
I'll have a look and see if I can work out the order of the 'com methods' very soon.
Thanks again, it is hugely appreciated :)
I don't have the DX11 SDK installed to check it, but it looks OK if you change _vtIDirect3D9 IDirect3D9 to a DX11 interface.
Oops, little typo there. Great catch.
Awesome. I'll have a play around and see if I can make sense of all this - hehe :biggrin:
I think I am getting close. But I am getting some errors when I call 'coinvoke'
Quotedx_test1.asm(185) : error A2114: INVOKE argument type mismatch : argument : 1
coinvoke(16): Macro Called From dx_test1.asm(185): Main Line Code
dx_test1.asm(185) : error A2022: instruction operands must be the same size
coinvoke(8): Macro Called From dx_test1.asm(185): Main Line Code
; ***** Tested to be ok *****
; D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, &d3dDevice, NULL, NULL);
invoke D3D11CreateDevice, NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, addr d3dDevice, NULL, NULL
mov ddResult, eax
invoke itoa, ddResult, addr szBuffer, 10
invoke SetWindowText, hWnd, addr szBuffer
; ***** Tested to be ok *****
; This line is not compiling
coinvoke d3dDevice, ID3D11Device, Release
The device creation works fine, but I can't release the device due to the above errors.
Am I calling 'coinvoke' correctly?
I think I am almost at the last piece of the puzzle (hopefully :lol:)
Try this,
coinvoke d3dDevice,IUnknown,Release
Nah, exactly the same error unfortunately. :(
This is what my d3d11.inc presently looks like. I am also including your dx9macro header to piggy-back off your coinvoke implementation.
; Interface IID's
; {db6f6ddb-ac77-4e88-8253-819df9bbf140}
IID_ID3D11Device TEXTEQU <{0db6f6ddbh,0ac77h,4e88h,{082h,053h,081h,09dh,0f9h,0bbh,0f1h,040h}}>
D3D11CreateDevice PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
_vtID3D11Device MACRO CastName:REQ
_vtIUnknown CastName
&CastName&_CheckCounter comethod10 ?
&CastName&_CheckCounterInfo comethod2 ?
&CastName&_CheckFeatureSupport comethod4 ?
&CastName&_CheckFormatSupport comethod3 ?
&CastName&_CheckMultisampleQualityLevels comethod4 ?
&CastName&_CreateBlendState comethod3 ?
&CastName&_CreateBuffer comethod4 ?
&CastName&_CreateClassLinkage comethod2 ?
&CastName&_CreateComputeShader comethod5 ?
&CastName&_CreateCounter comethod3 ?
&CastName&_CreateDeferredContext comethod3 ?
&CastName&_CreateDepthStencilState comethod3 ?
&CastName&_CreateDepthStencilView comethod4 ?
&CastName&_CreateDomainShader comethod5 ?
&CastName&_CreateGeometryShader comethod5 ?
&CastName&_CreateGeometryShaderWithStreamOutput comethod10 ?
&CastName&_CreateHullShader comethod5 ?
&CastName&_CreateInputLayout comethod6 ?
&CastName&_CreatePixelShader comethod5 ?
&CastName&_CreatePredicate comethod3 ?
&CastName&_CreateQuery comethod3 ?
&CastName&_CreateRasterizerState comethod3 ?
&CastName&_CreateRenderTargetView comethod4 ?
&CastName&_CreateSamplerState comethod3 ?
&CastName&_CreateShaderResourceView comethod4 ?
&CastName&_CreateTexture1D comethod4 ?
&CastName&_CreateTexture2D comethod4 ?
&CastName&_CreateTexture3D comethod4 ?
&CastName&_CreateUnorderedAccessView comethod4 ?
&CastName&_CreateVertexShader comethod5 ?
&CastName&_GetCreationFlags comethod1 ?
&CastName&_GetDeviceRemovedReason comethod1 ?
&CastName&_GetExceptionMode comethod1 ?
&CastName&_GetFeatureLevel comethod1 ?
&CastName&_GetImmediateContext comethod2 ?
&CastName&_GetPrivateData comethod4 ?
&CastName&_OpenSharedResource comethod4 ?
&CastName&_SetExceptionMode comethod2 ?
&CastName&_SetPrivateData comethod4 ?
&CastName&_SetPrivateDataInterface comethod3 ?
ENDM
ID3D11Device STRUCT
_vtID3D11Device ID3D11Device
ID3D11Device ENDS
I'm hopefully just missing something silly now.
I'll have to download the DirectX 11 SDK first to be of any help to you, sunday I'll have a look at it.
I have never touched DirectX 11 before, we will see...
It's not too dissimilar to DX9 in its early initialisation. So it is probably something silly that I am doing.
I think I may have nailed it. 8)
I can now force an exception if I do an unsafe release of the device followed by another release. So this is a good thing. Means it is working correctly.
Getting late here so I'll do some more testing in the morning. If all goes well I might have an empty DX11 render window with a coloured back buffer by the end of tomorrow. :biggrin:
Hi Lonewolff,
I have used the DirectX SDK from february 2010 to translate the includes for DX11.
Only translated the COM interfaces to initialize DX11 and to render a screen with a orange background color.
The rest is up to you. :biggrin:
Marinus
Nice one, I'll check it out. I am almost at the same stage with my attempt too. 8)
How did you get to that stage so quickly? I am still wrapping up the device context.
Have some experience with COM interface translations. :biggrin:
Hehe, you certainly do 8)
A great many thanks to Siekmanski. You have been extremely supportive. I'll be sure to make you proud. 8)
:t
Woot! My first DX11 render window, after many hours of debugging my interpretation of the few DX11 interfaces.
(https://i.imgur.com/VNmss2D.png)
Weighing in at 3 KB.