Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411573 Posts in 69386 Topics- by 58444 Members - Latest Member: darkcitien

May 04, 2024, 04:15:00 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)General programming discussion
Pages: 1 ... 5 6 [7] 8 9 ... 16
Print
Author Topic: General programming discussion  (Read 29274 times)
powly
Level 4
****



View Profile WWW
« Reply #120 on: September 07, 2017, 05:28:23 PM »

I'd say skip VAOs and attributes in GL and skip vertex buffers and input layouts in D3D. Just go with generic buffers for vertex attributes. The only vertex shader specific input you need is the vertex index. This results in the exact same operations performed by the hardware and saves a great amount of API hassle.
Logged
Crimsontide
Level 5
*****


View Profile
« Reply #121 on: September 07, 2017, 06:34:31 PM »

I'd say skip VAOs and attributes in GL and skip vertex buffers and input layouts in D3D. Just go with generic buffers for vertex attributes. The only vertex shader specific input you need is the vertex index. This results in the exact same operations performed by the hardware and saves a great amount of API hassle.

Actually, as much as I'd like to agree with you, there is still a lot of hardware out there where input layouts is faster than manual fetches from a vertex shader.  As far as AMD/NVidia are concerned I'm not sure, but I know (know as in have read, not personally experienced...) most of the Intel chips input layouts are much faster, as well as with many mobile GPUs.

As much as I'd love to see them ditch the IA and rework vertex shaders to be more of a geometry generation shader (the notion of 1:1 input vertex to output vertex is rather antiquated at this point IMHO), we sadly are not there yet.
Logged
Cheezmeister
Level 3
***



View Profile
« Reply #122 on: September 07, 2017, 09:14:28 PM »

I'm still quite fuzzy on the difference between VAOs and VBOs in OpenGL. Any good reading material that explains the difference in plain English?
Logged

෴Me෴ @chzmstr | www.luchenlabs.com ቒMadeቓ RA | Nextris | Chromathud   ᙍMakingᙌCheezus II (Devlog)
powly
Level 4
****



View Profile WWW
« Reply #123 on: September 08, 2017, 12:21:23 AM »

VAO is an OpenGL object holding bunch of vertex attribute and bind state, VBO is a bit of a misnomer since it refers to just any OpenGL buffer object that happens to be bound to a vertex attribute.

most of the Intel chips input layouts are much faster, as well as with many mobile GPUs.
This is most likely true but for any desktop NVIDIA/AMD card that even allows this kind of approach the performance is the same. And you're correct; this isn't the go-to solution yet. I kind of hope that some day it will be. In the meantime, it's a very neat shortcut if you do stuff that already requires a pretty beefy GPU.
Logged
qMopey
Level 6
*


View Profile WWW
« Reply #124 on: September 08, 2017, 10:36:59 AM »

https://en.wikipedia.org/wiki/Vertex_Buffer_Object

Pretty much all the buffer stuff. The point is you can make a buffer to upload data to the GPU through a big array, instead of calling immediate mode functions (glVertex3f et al).
Logged
powly
Level 4
****



View Profile WWW
« Reply #125 on: September 08, 2017, 12:17:14 PM »

The point is you can make a buffer to upload data to the GPU through a big array
Not only this but also to store it on the GPU so if subsequent frames use the same mesh you can reuse the data instead of resending it over PCI-E each time. Or you could generate the vertices on the GPU and then render them; great for generating all sorts of large procedural meshes. Essentially it saves on time spent moving data between RAM and VRAM.

You could also do vertex arrays straight from RAM. Essentially you don't bind anything as the current buffer. After this the offset pointer in glVertexAttribPointer refers to main memory instead of a GPU-side buffer and you can just give a normal CPU-side pointer to the data.
Logged
qMopey
Level 6
*


View Profile WWW
« Reply #126 on: September 08, 2017, 12:49:59 PM »

Just to clarify, a vertex array makes use of those old glVertexAttribPointer functions, as in, hard-coded attributes, right? And a VBO uses the generic attribute?
Logged
JWki
Level 4
****


View Profile
« Reply #127 on: September 09, 2017, 01:06:45 AM »

Just to clarify, a vertex array makes use of those old glVertexAttribPointer functions, as in, hard-coded attributes, right? And a VBO uses the generic attribute?


Vertex Array Objects aka VAOs simply store the state you set by using glVertexAttribPointer as well as the current VBOs being bound to the different slots. With modern OpenGL, you can use them in a way such that they only store the current input layout and use glBindVertexBuffer to mix that up with different vertex buffers, making it equivalent (more or less) to the input layout objects that other APIs have.
Logged
ferreiradaselva
Level 3
***



View Profile
« Reply #128 on: September 09, 2017, 08:48:01 AM »

I'd say skip VAOs and attributes in GL and skip vertex buffers and input layouts in D3D. Just go with generic buffers for vertex attributes. The only vertex shader specific input you need is the vertex index. This results in the exact same operations performed by the hardware and saves a great amount of API hassle.
Unfortunately, you can't skip since it's obligatory to have at on GL >= 3.2 and core, which is the whole upsetting thing.


You could also do vertex arrays straight from RAM. Essentially you don't bind anything as the current buffer. After this the offset pointer in glVertexAttribPointer refers to main memory instead of a GPU-side buffer and you can just give a normal CPU-side pointer to the data.
VBOs are at least very flexible, I can't complain about it. I'm using similar approach as you describe, since I modify the vertices (against the model matrix) on client-side.


I've done that before I knew about what VAOs were.
In tinygl I create a single VAO because it is required, and I never do anything with it. https://github.com/RandyGaul/tinyheaders/blob/master/tinygl.h#L291-L293

That's what I will be doing today Smiley.

But when we say "clean up" it is very subjective! Personally I think hiding all of these attribute states behind a VAO is a poor use of abstraction. VAOs are an abstraction of state. This abstraction does hide the details in the above link, but personally I think these details are important to lay out in the open. It gives a clearer picture of exactly how GL is used in tinygl.

I agree with that. Also, if you decide to target computers with an older GL version, if you remove VAOs from the way, you have at least something less to worry during porting.
Logged

powly
Level 4
****



View Profile WWW
« Reply #129 on: September 10, 2017, 04:42:28 PM »

Unfortunately, you can't skip since it's obligatory to have at on GL >= 3.2 and core, which is the whole upsetting thing.
This is not true. While you do need a VAO to bind VBOs to vertex attributes, you can just not use vertex attributes at all. To load data you just bind a generic buffer and read it based on gl_VertexID.

VBOs are at least very flexible, I can't complain about it. I'm using similar approach as you describe, since I modify the vertices (against the model matrix) on client-side.
VBOs are flexible but I find the setup overly verbose and thus a bit clumsy.
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #130 on: September 15, 2017, 04:32:36 PM »

this is the best thing i've ever seen





Link is dead, what was it? mirror?
Logged

oahda
Level 10
*****



View Profile
« Reply #131 on: September 16, 2017, 12:57:26 AM »

Weird. I think it was this:



Logged

powly
Level 4
****



View Profile WWW
« Reply #132 on: September 19, 2017, 12:55:45 PM »

Unfortunately, you can't skip since it's obligatory to have at on GL >= 3.2 and core, which is the whole upsetting thing.
This is not true.
Ha, finally tested this and found out I was completely wrong! You still don't have to have any VBOs but a VAO is strictly required.
Logged
oahda
Level 10
*****



View Profile
« Reply #133 on: September 29, 2017, 02:35:20 AM »

https://codegolf.stackexchange.com/questions/11880/build-a-working-game-of-tetris-in-conways-game-of-life
Logged

Cheezmeister
Level 3
***



View Profile
« Reply #134 on: September 29, 2017, 12:13:19 PM »


Unless that's running inside Minecraft on a virtual workstation in Half-Life 3, not yodawg enough. =P
Logged

෴Me෴ @chzmstr | www.luchenlabs.com ቒMadeቓ RA | Nextris | Chromathud   ᙍMakingᙌCheezus II (Devlog)
oahda
Level 10
*****



View Profile
« Reply #135 on: October 02, 2017, 06:39:07 AM »

lololol

Logged

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #136 on: October 02, 2017, 06:54:58 AM »

What he's actually doing is this, right?

Code:
let i = 15;
while(i-- > 10)
{
    //Do something
}
Logged

oahda
Level 10
*****



View Profile
« Reply #137 on: October 02, 2017, 07:28:07 AM »

yes Cheesy

disclaimer: op was joking too
Logged

ferreiradaselva
Level 3
***



View Profile
« Reply #138 on: October 02, 2017, 05:30:54 PM »

https://michaldrobot.com/2014/04/01/gcn-execution-patterns-in-full-screen-passes/

tldr: when drawing a background, drawing a single triangle that covers the entire window is faster than drawing two triangles (a quad). 10% faster.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #139 on: October 03, 2017, 07:20:26 AM »

Clever! I'd never thought of doing it that way.
Logged

Pages: 1 ... 5 6 [7] 8 9 ... 16
Print
Jump to:  

Theme orange-lt created by panic