MASM FORUM MEMBERS: Please disregard this post,...as it turns out, the error number I received from D3D11CreateDevice was correct,...it just took awhile to find it. SORRY !!!
Another seemingly simple question:
I'm writing a DirectX app, and I'm having a really dumb problem.
I'm invoking D3D11CreateDevice (http://msdn.microsoft.com/en-us/library/windows/desktop/ff476082(v=vs.85).aspx)
There are a number of parameters, and one of them is a value from a C++ enumeration (D3D_FEATURE_LEVEL):
Defined in D3DCommon.h, from the Windows Seven SDK.
typedef enum D3D_FEATURE_LEVEL
{ D3D_FEATURE_LEVEL_9_1 = 0x9100,
D3D_FEATURE_LEVEL_9_2 = 0x9200,
D3D_FEATURE_LEVEL_9_3 = 0x9300,
D3D_FEATURE_LEVEL_10_0 = 0xa000,
D3D_FEATURE_LEVEL_10_1 = 0xa100,
D3D_FEATURE_LEVEL_11_0 = 0xb000
} D3D_FEATURE_LEVEL;
You can call D3D11CreateDevice with a value of NULL for the array, and a value of zero for the number of elements in the array, and this array will automatically be provided to D3D11CreateDevice.
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1,
};
This works correctly, I get a return of S_OK, and the variable returned (the ninth parameter, pFeatureLevel) indicates which D3D_FEATURE_LEVEL succeeded. I get a valid return value for this parameter, also (D3D_FEATURE_LEVEL_9_1).
What I can't figure out how to do is create an array with just a single value (D3D_FEATURE_LEVEL_11_0, b000h).
I tried creating a DWORD variable in my data section, and with a couple of mov instructions setting this equal to D3D_FEATURE_LEVEL_11_0. This compiles, but, D3D11CreateDevice FAILS.
...It's weird because the variable that receives the value of the successful D3D_FEATURE_LEVEL value is a DWORD,...
an enumeration is like a cross between a structure and an equate
(i.e., an index is created, but no data is generated)
i don't know if masm really supports enumerations, but you might try something like this
EnumName STRUCT
Elem1 = 1
Elem2 = 2
Elem3 = 3
EnumName ENDS
or
EnumName STRUCT
Elem1 EQU 1
Elem2 EQU 2
Elem3 EQU 3
EnumName ENDS
DAVE !!!
Sorry, the code DOES work with a DWORD for the array value (or, values).
The Microsoft documentation is huge, and finding the correct error code took awhile.
Here it is:
DXGI_ERROR_UNSUPPORTED
0x887A0004
The requested functionality is not supported by the device or the driver.
That's exactly what I wanted to know.
yah - but generation of data shouldn't be necessary
it can be resolved at assemble-time to a constant
you might also do some reading on TYPEDEF - there may be some special way to handle enumerations
include \masm32\include\masm32rt.inc
.code
start:
if 0
; C/C++
typedef enum D3D_FEATURE_LEVEL
{
D3D_FEATURE_LEVEL_9_1 = 0x9100,
D3D_FEATURE_LEVEL_9_2 = 0x9200,
D3D_FEATURE_LEVEL_9_3 = 0x9300,
D3D_FEATURE_LEVEL_10_0 = 0xa000,
D3D_FEATURE_LEVEL_10_1 = 0xa100,
D3D_FEATURE_LEVEL_11_0 = 0xb000
} D3D_FEATURE_LEVEL;
else
; assembler
D3D_FEATURE_LEVEL_9_1 = 9100h
D3D_FEATURE_LEVEL_9_2 = 9200h
D3D_FEATURE_LEVEL_9_3 = 9300h
D3D_FEATURE_LEVEL_10_0 = 0a000h
D3D_FEATURE_LEVEL_10_1 = 0a100h
D3D_FEATURE_LEVEL_11_0 = 0b000h
endif
MsgBox 0, hex$(D3D_FEATURE_LEVEL_11_0), "The value:", MB_OK
exit
end start
P.S.: Dave's versions work, too (it just creates an empty struct):
EnumName STRUCT
Elem1 EQU 1
Elem2 EQU 2
Elem3 EQU 3
EnumName ENDS
Note the difference between Elem2 equ 2, Elem2 equ <2>, and Elem2 = 2 is that they are all integer constants defined at assembly time, but Elem2 equ 2 cannot be redefined further down.
Strings can be redefined any time:
My$ equ <Dave>
% @CatStr(<print "&My$ is a great guy", 13, 10>)
tmp$ CATSTR <print ">, My$, < is a great guy", 13, 10>
tmp$
My$ equ <Zen>
tmp$ CATSTR <print ">, My$, < is a great guy, too", 13, 10>
tmp$
Elem2 equ <2>
that form of EQU is actually a TEXTEQU