D3D problem

Discussions related to graphics (2D and 3D), animation and games programming
Ric
Posts: 56
Joined: Tue 17 Apr 2018, 21:03

D3D problem

Post by Ric »

Not sure what the problem is but I am trying to dip my toe in to D3Direct, I have taken Richard's tutorials and modified the DIMs to enable more verticies, but when the number of vertices gets to 258 the program stops rendering the triangles.

Is there a setting that allows maximum memory allocated that is not DIM vertices or DIM indices or vertices count in the render section. I have changed all these to 899 except the vertices count which is set to 900

DIM vertices{(899)} = SimpleVertex{}
DIM bd{} = D3D11_BUFFER_DESC{}
bd.Usage% = D3D11_USAGE_DEFAULT
bd.ByteWidth% = DIM(SimpleVertex{}) * (DIM(vertices{()},1)+1)
bd.BindFlags% = D3D11_BIND_VERTEX_BUFFER
bd.CPUAccessFlags% = 0


DIM indices{(899)} = WORD{}
bd.Usage% = D3D11_USAGE_DEFAULT
bd.ByteWidth% = DIM(WORD{}) * (DIM(indices{()},1)+1) :REM * (DIM(indices{()},2)+1)
bd.BindFlags% = D3D11_BIND_INDEX_BUFFER
bd.CPUAccessFlags% = 0
InitData.pSysMem% = indices{(0)}


SYS ID3D11DeviceContext.VSSetShader%, pImmediateContext%, pVertexShader%, NULL, 0
SYS ID3D11DeviceContext.VSSetConstantBuffers%, pImmediateContext%, 0, 1, ^pConstantBuffer%
SYS ID3D11DeviceContext.PSSetShader%, pImmediateContext%, pPixelShader%, NULL, 0
SYS ID3D11DeviceContext.PSSetConstantBuffers%, pImmediateContext%, 0, 1, ^pConstantBuffer%
SYS ID3D11DeviceContext.DrawIndexed%, pImmediateContext%, 900, 0, 0



Is there something else i need to change?

Regards Ric

DDRM
Posts: 200
Joined: Mon 02 Apr 2018, 18:04

Re: D3D problem

Post by DDRM »

Hi Ric,

I've used thousands of vertices in D3D9, but I see you are using D3D11. You are working from the tutorials and source files on the wiki?

I'll try to take a look, but I'm not sure my eyes will be any better than yours...

Best wishes,

D

Ric
Posts: 56
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

Cheers D

Ye the code is straight from the tutorials. Any input would be gratefully received.

Ric

ps. just got in after a long day at work, i will post a link to the full code tomorrow

Ric
Posts: 56
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »


Ric
Posts: 56
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

Hi DDRM

Hope you didn't spend too much time trying to solve the problem.
In a moment of lucidity during MANFLU I realised that the error was not at 258 vertices but 255, which happens to be a bytes worth of course.
A simple change to the create indices routine incorporating the high byte

Code: Select all

      DIM indices{(num_of_verticies%-1)} = WORD{}
      FOR r% = 0 TO num_of_verticies%-1 STEP 3
        q%= r%+2
        indices{(q%)}.l& = r%
        indices{(q%)}.h& = (r%AND&FF00)>>8
        indices{(q%-1)}.l& = r%+1
        indices{(q%-1)}.h& = ((r%+1)AND&FF00)>>8
        indices{(q%-2)}.l& = r%+2
        indices{(q%-2)}.h& = ((r%+2)AND&FF00)>>8
      NEXT r%
Here is a working example

https://1drv.ms/u/s!AqibHqCkE1VQ-1VUsMC ... Z?e=UyXhvU

Regards Ric

Ric
Posts: 56
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

This does lead to another problem however
Combining low and high bytes to make a word only gives 65536 verticies.
How do you create more?

RichardRussell
Posts: 535
Joined: Tue 15 Oct 2019, 09:10

Re: D3D problem

Post by RichardRussell »

Ric wrote:
Wed 12 Feb 2020, 21:52
Combining low and high bytes to make a word only gives 65536 verticies.
How do you create more?
The documentation at MSDN states that "An index buffer contains a sequential set of 16-bit or 32-bit indices" (my emphasis) so there would not appear to be a 65536-vertex limit.

But I'd be interested to know why you are using Direct3D11 rather than D3D8 or D3D9; it's very considerably more complicated and doesn't have the convenience - and cross-platform compatibility - afforded by the supplied libraries. Are you planning to do shader programming, or something else not supported by Direct3D9?
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ric
Posts: 56
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

To be fair, i am using it because it was what i stumbled across. After my initial failure at d3d11 i had a look at d3d9 and i can not get on with the single letter variables used, the documentation in the tutorials for d3d11 is far more descriptive and given a little bit or perseverance it becomes clear. i am gaining confidence with the structure and am happy to pursue it.

My own goals are personal and i am not that interested in producing a cross platform product yet.
At the moment i am just happy playing.

May i once again thank you for producing such a fantastic product in BB4W, it has rekindled a long lost hobby.

Ric

RichardRussell
Posts: 535
Joined: Tue 15 Oct 2019, 09:10

Re: D3D problem

Post by RichardRussell »

Ric wrote:
Fri 21 Feb 2020, 21:02
i had a look at d3d9 and i can not get on with the single letter variables used
Where are you seeing these "single letter variables"? The documentation of the D3D library (in fact libraries) doesn't use single-letter variables in its function descriptions; for example FN_loadtexture(pdev%,file$) where pdev% is a pointer to the D3D device and file$ is the path/name of the image file.

Obviously my main concern is that by using Direct3D11 you are tying yourself to Windows whereas if using the supplied libraries you can very easily port your programs to other platforms using BBC BASIC for SDL 2.0. I try very hard not to write platform-specific programs these days, when the great majority of computers (literally) in people's hands are running Android or iOS.
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ric
Posts: 56
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

The single variables I was referring to are in PYRAMID and the D3D9 library.

After some consideration i have decided that d3d11 is overly complicated! No surprise there then. I would like to start d3d9 by transposing the directxtutorial.com so that i can understand what is going on. The only problem is that i can not find a list of CONSTANTS with their NUMERICAL values.
Has anyone got one that they could post or can someone point me to a website that does?

Kind Regards
Ric