News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

64-bit DirectX 11 - Part 2 - Text, Sphere

Started by aw27, June 04, 2018, 04:05:31 AM

Previous topic - Next topic

felipe

 :biggrin: I installed (reinstalled  :P) that sdk but i had the same problem. Yes, i guess is the graphics card.  If i have time i will check where the program firstdetects an error.  :idea:

aw27

Quote from: felipe on June 05, 2018, 09:02:55 AM
:biggrin: I installed (reinstalled  :P) that sdk but i had the same problem. Yes, i guess is the graphics card.  If i have time i will check where the program firstdetects an error.  :idea:

I tested in a Windows 8.1 64-bit virtual machine and could not run the program, same error you got. dxdiag also reports Directx 11 but I know from experience that applications always fall back to 9.3 because the graphics card is some "virtual crapware", I mean vmWare.

I had to install the Windows DirectX 11 SDK June 2010 AND the Windows SDK 8.1 in order for the debug build of my demo start reporting on dbgview.exe. It reports this:
[4080] D3D11 ERROR: ID3D11Device::CreateVertexShader: Invalid shader version provided: vs_4_0 [ STATE_CREATION ERROR #167: CREATEVERTEXSHADER_INVALIDSHADERTYPE]

I could not make any sense of it (yet).

I placed a break point after this instructions:
   ; Create shader objects: 1) Vertex Shader
   coinvoke d3d11Device, ID3D11Device, CreateVertexShader, r12, r13, NULL, offset VS

and the return value is:
0x80070057

I have no idea of what is wrong and what error 0x80070057 has to do with CREATEVERTEXSHADER_INVALIDSHADERTYPE








Siekmanski

QuoteI have no idea of what is wrong and what error 0x80070057 has to do with CREATEVERTEXSHADER_INVALIDSHADERTYPE

If it falls back to direct3D9 then the highest shader version available is 3.0
Creative coders use backward thinking techniques as a strategy.

Lonewolff

Works fine for me  :t

I noticed that you aren't releasing a few things on exit though, which is causing a bit of a leak.

Quote
D3D11 WARNING: Process is terminating. Using simple reporting. Please call ReportLiveObjects() at runtime for standard reporting. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: Live Producer at 0x00000000035640E0, Refcount: 6. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003AA9D90, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003D8E2B0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003B97920, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003B97B30, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003B97500, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003B96AB0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003D9AD30, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003D9AF50, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003D9C310, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003D9DF80, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000000599BD0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F356B0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F60D30, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F60FA0, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F656C0, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F65AC0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F65D60, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F8A730, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F92E80, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F93280, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F8F3D0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F939A0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F325F0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F929F0, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F7F9E0, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F80C70, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F7EF90, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING:    Live Object at 0x0000000003F34E90, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: Live                         Object :     28 [ STATE_CREATION WARNING #0: UNKNOWN]
The program '[524] dx11_64App3.exe' has exited with code 0 (0x0).

Felipe's problem may be caused by a three things that come to mind.


  • If his device is falling back to a 9.3 device the shader creation will fail as Siekmanski mentioned.
  • His GPU might not support hardware acceleration on DX11. I'd recommend 'failing back' to a WARP device on device creation failure. This will immediately expand your target audience.
  • Build as non-debug device. There are no-redistributables for the debug library. The end user would have to have the same version of SDK installed for the program to run.

felipe

 :biggrin: Hey ascended, is nice to see you contributing with your knowledge to the forum. Thank you very much!  :icon14:


felipe

Now this could be a little weird, the control panel from the intel graphics and multimedia says in the section of information system:
DirectX Version= 10.1
Even if dxdiag still shows directx 11... :idea:

felipe

From this site: http://www.hb-studios.com/forum/index.php?topic=2100.0

QuoteYou need to look under the 'Display Devices' details and see what DDI Version is shown. This will give you the version of Direct X your card supports.

Here's an example from a Radeon HD 5800 card. As you can see, it is only DX 10.1 compatible.



Graphics cards and System Settings are not always the same when it comes to DX compatibility. Most system theses days are DX 11 but not all graphics cards are.

So, probably this is my case.  :(

felipe


Lonewolff

The WARP adapter fall back suggestion will fix that.  :t

This explains why my exe don't work for you either as I still need to add this myself.

felipe

Thanks ascended, if is really possible, will be great that fix so i can play with directx 11 programs too.  :bgrin:
If not i will have to wait until i get a better gpu.  :idea:

Lonewolff

Quote from: felipe on June 05, 2018, 01:08:03 PM
Thanks ascended, if is really possible, will be great that fix so i can play with directx 11 programs too.  :bgrin:
If not i will have to wait until i get a better gpu.  :idea:

Yep, WARP will run on any hardware where it is DirectX compatible or not.

https://msdn.microsoft.com/en-us/library/windows/desktop/gg615082(v=vs.85).aspx

felipe

I still can't run this program (i have the same video card yet). I tried to use the warp trick but didn't work. But maybe because in my system it's the d3d10warp.dll but not the d3d11warp.dll. Anyone know where to find (or how to install) this later dll? Thanks.  :thup:

Caché GB

Hi felipe

I think the OP has taken a ride on Halley's comet.

With that being said, this is how you may solve your issue.

First things first, or last. You need to properly set up your window, the one you will
send to D3D in SwapChainDesc.OutputWindow. See how Siekmanski sets up the
window here.

Require advice in wrapping DX11 please : Reply #17
http://masm32.com/board/index.php?topic=7026.15

In DX11_test.zip/DX11.Asm

The emphasis is on SetRect and AdjustWindowRectEx.

OK now before you call D3D11CreateDeviceAndSwapChain make an array with all the
feature sets in them like this


     local  FeatureLevels[4]:dword
     local  NumElements:qword
     local  Feature:qword

            ...

            and  Feature, null                                              ; Shows which D3D_FEATURE_LEVEL was selected
            mov  NumElements, LENGTHOF FeatureLevels

            mov  FeatureLevels[0*dword], D3D_FEATURE_LEVEL_11_1
            mov  FeatureLevels[1*dword], D3D_FEATURE_LEVEL_11_0
            mov  FeatureLevels[2*dword], D3D_FEATURE_LEVEL_10_1
            mov  FeatureLevels[3*dword], D3D_FEATURE_LEVEL_10_0


then send this array in the call.


            lea  rdx, (CDirect3d ptr[r15]).m_DeviceContext
            mov  qword ptr[rsp+58h], rdx
            lea  rdx, Feature
            mov  qword ptr[rsp+50h], rdx
            lea  rdx, (CDirect3d ptr[r15]).m_Device
            mov  qword ptr[rsp+48h], rdx
            lea  rdx, (CDirect3d ptr[r15]).m_SwapChain
            mov  qword ptr[rsp+40h], rdx
            lea  rdx, SwapChainDesc
            mov  qword ptr[rsp+38h], rdx
            mov  qword ptr[rsp+30h], D3D11_SDK_VERSION
            mov  rdx, NumElements
            mov  qword ptr[rsp+28h], rdx
            lea  rdx, FeatureLevels
            mov  qword ptr[rsp+20h], rdx
            mov   r9, D3D11_CREATE_DEVICE_SINGLETHREADED
            xor   r8, r8
            mov  rdx, D3D_DRIVER_TYPE_HARDWARE
            xor  rcx, rcx
           call  D3D11CreateDeviceAndSwapChain
           test  eax, eax
             jz   @F
         invoke  Direct3d.ErrMessage, 04
         @@:


Now D3D can chose the latest level supported by your gfx. The value returned in Feature
will indicate which D3D_FEATURE_LEVEL_XX_X  was selected.

If this helps don't forget to like, share and subscribe.
Caché GB's 1 and 0-nly language:MASM

felipe

There are some undefined symbols in your code, like: D3D_FEATURE_LEVEL_11_1 or CDirect3d which for now i can't work to put in an include file (if i understood well  :icon_idea:). Unfortunately i still don't have extra time to code programs in assembly  :undecided:. Thanks for your help anyway  :thup:.

Caché GB

No worries felipe. Thanks for the like.


It turns out D3D_FEATURE_LEVEL_11_1 is a TYPEDEF which
should reside in a (your) d3dcommon.inc file, see below.



TITLE  d3dcommon.inc

    ...

D3D_FEATURE_LEVEL TYPEDEF DWORD
D3D_FEATURE_LEVEL_9_1   EQU 09100h
D3D_FEATURE_LEVEL_9_2   EQU 09200h
D3D_FEATURE_LEVEL_9_3   EQU 09300h
D3D_FEATURE_LEVEL_10_0  EQU 0A000h
D3D_FEATURE_LEVEL_10_1  EQU 0A100h
D3D_FEATURE_LEVEL_11_0  EQU 0B000h
D3D_FEATURE_LEVEL_11_1  EQU 0B100h
D3D_FEATURE_LEVEL_12_0  EQU 0C000h
D3D_FEATURE_LEVEL_12_1  EQU 0C100h

    ...



So you should add this 

D3D_FEATURE_LEVEL_11_1  EQU 0B100h

into AW's d3d11.inc file, line 161. Level - Easy.


Don't sweat about _THIS CDirect3d. It's just a structure with methods and variables (Class Template)
which when instanced on the Heap makes for an object that serves your application (OOP).

This CDirect3d structure has nothing to do with D3D or any of its COM based methods.
It is in house and belongs to one's own framework/engine. Structures like this proved
abstraction capability for components like Actor, Camera, Scene and so on and so forth
and things like that.


Updated code for copy 'n past into AW's dxMain.inc file. Level - Intermediate.



InitializeDirect3d11App proc

            ...

     local  FeatureLevels[4]:dword
     local  NumElements:qword
     local  Feature:qword

            and  rsp, -10h
            add  rsp, -60h

            ...

            and  Feature, null
            mov  NumElements, LENGTHOF FeatureLevels             ; Number of Elements = 4

            mov  FeatureLevels[0*dword], D3D_FEATURE_LEVEL_11_1  ; Highest FEATURE_LEVEL aimed for in first element.
            mov  FeatureLevels[1*dword], D3D_FEATURE_LEVEL_11_0
            mov  FeatureLevels[2*dword], D3D_FEATURE_LEVEL_10_1
            mov  FeatureLevels[3*dword], D3D_FEATURE_LEVEL_10_0

       ; Create our SwapChain

            mov  rcx, NULL
            mov  rdx, D3D_DRIVER_TYPE_HARDWARE
            mov  r8, NULL
            mov  r9, 0

            lea  rax, FeatureLevels              ; <--- Note change No.1
            mov  qword ptr [rsp+20h], rax

            mov  rax, NumElements                ; <--- Note change No.2
            mov  qword ptr [rsp+28h], rax        ; 'or'  mov  qword ptr[rsp+28h], LENGTHOF FeatureLevels

            mov  dword ptr [rsp+30h], D3D11_SDK_VERSION
            lea  rax, swapChainDesc
            mov  qword ptr [rsp+38h], rax
            lea  rax, SwapChain
            mov  qword ptr [rsp+40h], rax
            lea  rax, d3d11Device
            mov  qword ptr [rsp+48h], rax

            lea  rax, Feature                    ; <--- Note change No.3
            mov  qword ptr [rsp+50h], rax

            lea  rax, d3d11DevCon
            mov  qword ptr [rsp+58h], rax
           call  D3D11CreateDeviceAndSwapChain ; Create our SwapChain
            cmp  eax, 0
            jnz  @exit

            ...



After the D3D11CreateDeviceAndSwapChain call returns, if the
local variable Feature has the value 0A000h or 0A100h
( D3D_FEATURE_LEVEL_10_0 'or' D3D_FEATURE_LEVEL_10_1 ) then
your gfx is running DX11 'on' DX10 and you can access
all the, wait for it

Common COM Components.

I have no idea what I said there, but it sounds intelligent.


Things for DX11 only, like Hardware Tessellation will BREAK.
Also Shader Modal 5 is a no no. Use 4.0 or 4.1 instead.


Hope that clears things up for you and all is well.
Caché GB's 1 and 0-nly language:MASM