|
|
|||||||
| Home | Register | Downloads | FAQ | Members List | Calendar | Arcade | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 | |
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
I came across the following in NVIDIA's ARB Vertex Program tutorial presentation. On page 54, the following is listed: Quote:
This would imply that when using deprecated features (e.g glColor4f, glColorPointer), the vertex program must reference conventional attributes (vertex.color), whilst attributes assigned by glVertexAttribPointer would reference the specific attribute index (vertex.attrib[]) to which they have been assigned. The only exception is vertex.attrib[0], which is aliased to vertex.position (according to the OpenGL 2 spec). Last edited by JohnJack; March 2nd, 2011 at 19:00.. |
|
|
|
|
| Advertisement | [Remove Advertisement] |
|
|
|
|
|
#22 | |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Quote:
I was hoping that we would need to recompile each shader only once, but now we already have two variations : - in cases where the NV2A seems to apply the mvp itself (without any mention of that in the shader), we have to append that rotation ourselves - when a shader is used in immediate mode rendering, the attributes must be conventional - when we're rendering from pointers it should specify generic attributes. I was thinking - instead of using glVertexAttribPointer, maybe we should use the (deprecated) conventional gl*Pointer functions as much as possible, so that the shader can be used for both rendering methods. (I really don't want to generate different versions of a shader for difference usage-scenarios). Any objections against this? PS: Another solution could be to do what the D3D version of Cxbx and Dxbx does : Collect all immediate mode vertex data into a buffer and render that with one call. The advantage of that is, that everything can be drawn using glVertexAttribPointer (and thus allows us using just generic shader attributes), but it would require a bit of housekeeping - as only at the end of the data we know for sure which attributes where supplied. This brings me to another question: I've seen shaders that use attributes that where not part of a stream - am I correct in assuming that the values set to these attributes using glVertexAttrib stay the unmodified per-vertex and can thus be seen as a few more constants?
__________________
Dxbx dev - Delphi FTW ;-) Last edited by patrickvl; March 2nd, 2011 at 21:47.. |
|
|
|
|
|
|
#23 | |||
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
If using gl*Pointers is easier to maintain than using glVertexAttrib*, then by all means use it. I'm biased towards generic attributes. Maintaining 1 shader is better than 2. However, I don't understand the following: Quote:
Quote:
Quote:
|
|||
|
|
|
|
|
#24 | |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Quote:
However in immediate mode, when the Begin command is received we don't know what kind of data setters will follow until we've received the End command. What I meant was, that we could collect all vertex data send to us in between those two calls, create buffers for each type, and draw that using vertex attribute pointers, so that we can suffice with just the vertex shader variant that's using generic attributes. The SDK docs don't mention this - but one of the samples (CompressedVertices) uses a vertex shader that reads v9 (Texcoords) without any mention of this in the sample code. (Although to be honest, this sample doesn't even use textures, so it might well be an oversight in the shader.) But the quote you gave on glVertexAttrib does indicate that attributes set with that API (and not supplied via a pointer) maintain their value, so they can indeed be seen as a constant. About this caveat : The Xbox1 D3D implementation supports a few NV2A specific data types that are not available on the PC version of D3D8 (nor D3D9); In Dxbx we inherited code from Cxbx that converted those types to types that are supported;
__________________
Dxbx dev - Delphi FTW ;-) |
|
|
|
|
|
|
#25 | ||||
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
Quote:
Quote:
Quote:
The glVertexAttribPointer spec states: Quote:
The documentation for these functions has all of the information you need. Last edited by JohnJack; March 3rd, 2011 at 10:49.. |
||||
|
|
|
|
|
#26 | |||
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Quote:
So *if* we're going to convert immediate-mode rendering to buffer-based rendering (to simplify the vertex shader recompiling), it would mean building up buffers for each attribute that's written to between the first and last vertex position (attribute values send prior to the first vertex position can be set directly using glVertexAttrib of course, so these won't need a buffer). Also note in this scenario that all changing attributes will need to have a specific value alongside each vertex position, or else the buffers won't line up anymore. This implies lots of repeating values (especially for attributes that don't change all that much) - sure it's overhead, but it's the only way to get this working. (It's either that, or juggling with various vertex shader variants.) Quote:
Quote:
By the way, if we decide to keep immediate-mode rendering (and thus don't collect vertex data values into buffers) the unsupported data-types (NORMPACKED3 and FLOAT2H) won't bite us, as the various SetVertexData calls don't support these types (pfew!)
__________________
Dxbx dev - Delphi FTW ;-) |
|||
|
|
|
|
|
#27 | |
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
Quote:
Programming One or More Streams (Direct3D 9) (Windows) Btw, converting all of your rendering code to use conventional attributes would be easier. You would just have to modify your shader to use conventional attributes. Last edited by JohnJack; March 3rd, 2011 at 13:44.. |
|
|
|
|
|
|
#28 |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Oh, it's not the copying, but the accompanying conversions that I want to avoid! For example, the 'Cartoon' sample (showing a yellow cartoon-shaded Robot) dropped from 60 fps to 7 fps when I started converting D3D vertex buffers on every frame. I had to do that in my 'less patching' approach (based on D3D8), which is on-hold right now since I'm researching this push-buffer emulation using OpenGL. Sure, a CRC based cache can alleviate that of course, but I'd rather switch over to OpenGL entirely.
__________________
Dxbx dev - Delphi FTW ;-) |
|
|
|
|
|
#29 | ||
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Quote:
Or are you referring to the fact that immediate-mode drawing requires no buffering if we use conventional attributes in the recompiled shader? I can see the logic in that, but there's one little problem to solve in that approach: Unmapped attributes; For most vertex attributes, there is a conventional setter, but vertex.attrib[6] and [7] have no setter. Also, if the card only supports 4 texture channels, vertex.attrib[13], [14] and [15] are also not accessible using conventional setters. And then there's the restriction on allowed GL calls between glBegin/glEnd : Quote:
__________________
Dxbx dev - Delphi FTW ;-) |
||
|
|
|
|
|
#30 |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Wait a minute - there's another solution possible too! Instead of going with conventional shader inputs, just to support immediate mode rendering, we could instead use generic attributes by mapping the immediate mode data onto generic attributes, so that a glColor(...) call becomes a glVertexData(3, ...) call, etc. That would allow all inputs, still takes only one vertex shader variant and wouldn't require a buffer for immediate mode rendering! Would that be possible/wise?
__________________
Dxbx dev - Delphi FTW ;-) |
|
|
|
|
|
#31 | ||
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
Quote:
! The flexibility of OpenGL is one of the reasons many implementations are generally slower than their Direct3D counterparts.Regarding your earlier question. Quote:
Multitexturing isn't as simple using TexCoordPointer as it is with using VertexAttribPointer, as you have to specify the active texture unit that uses your texture coordinates. If an implementation supports EXT_direct_state_access, MultiTexCoordPointerEXT could be used to alleviate that problem. However, that extension is not supported by current legacy products from AMD or NVIDIA (pre-Geforce 6 and pre-Radeon HD cards), nor is it supported by Intel. Anyway, it is unlikely that your emulator will run on a GPU whose OpenGL implementation cannot handle 8 texture coordinate sets. One conventional attribute that isn't supported on most graphics cards is vertex.weight, as few cards (atleast on Windows) support ARB_vertex_blend. Thus it can only be set using the attribute pointer (+1 for generic attributes). The main benefit of conventional attributes is that it improves the readability of the code. Generic attributes are forward compatible (supported in the core profiles of OpenGL 3+), although this has little meaning if deprecated functionality continues to be supported (not a bad thing). Last edited by JohnJack; March 3rd, 2011 at 18:25.. |
||
|
|
|
|
|
#32 |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Oops, I just realised that using glVertexAttrib will probably not work with the fixed function pipeline! I fear we'll have to settle for a mixed shader : All conventional attributes as-is, all other slots using generic attributes, even though it's not advised (as stated page 56 here).
__________________
Dxbx dev - Delphi FTW ;-) |
|
|
|
|
|
#33 | |
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
Quote:
Last edited by JohnJack; March 3rd, 2011 at 19:02.. |
|
|
|
|
|
|
#34 | |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Quote:
Actually, it's quite simple to make the code conditionally compile either to use generic attributes or conventional attributes; I've done most of the work already Edit : Here's the final switch. As I said : not much code.
__________________
Dxbx dev - Delphi FTW ;-) Last edited by patrickvl; March 3rd, 2011 at 19:40.. |
|
|
|
|
|
|
#35 | |
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
Quote:
EDIT: On looking at your code, I noticed that you commented out the glScalef call that is required to make the coordinate system of OpenGL left-handed. The transformation shader does not take this into account either. Is this handled elsewhere in your code? If you focus on pure fixed function vertex processing, where you know the inputs, and the expected output, you should be able to make the necessary transformations to the contents in the push-buffer to make the result appear on the screen. Last edited by JohnJack; March 4th, 2011 at 00:42.. |
|
|
|
|
|
|
#36 |
|
Banned
Join Date: Feb 2011
Location: USA
Posts: 34
|
JohnJack is right about WINE project, they really have good info about layering D3D8/9 on top of OpenGL. It is good a way of obtaining information about it
|
|
|
|
|
|
#37 | |
|
Registered User
![]() Join Date: Oct 2009
Posts: 58
|
Could asking around on OpenGL.org help? Quote:
Last edited by Shock120; March 4th, 2011 at 17:09.. |
|
|
|
|
|
|
#38 | |
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
I saw in Revision 1619 of your push buffer code: Quote:
. Plus, you also imported some stuff from WINE. Is it working in the way you expect?
Last edited by JohnJack; March 5th, 2011 at 15:10.. |
|
|
|
|
|
|
#39 |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2008
Location: Netherlands (GMT+1)
Posts: 415
|
Well, yes and no; If I reproduce the 'Vertices' SDK sample in a test app, the wined3d 'transform_projection' code works for both immediate and deferred rendering (with a simple shader) and for immediate mode (without a shader). (Deferred rendering without a shader doesn't show up, I assume that's only logical because the fixed-function pipeline doesn't handle generic vertex attrib pointers.) However, when I run the Vertices sample inside Dxbx I still see nothing. The problem is, that I had to alter a few things in the test app to get things rendering: - The 'SuperSampleScale' z component send to the Xbox push-buffer is 16777215, which needs to be scaled down to 1 to get something on-screen. - Also, the shader needs to be extended with a mvp transformation (although I wouldn't expect that to be necessary...) On the bright side, the projection-view matrix used by the Vertices sample when running inside Dxbx is identical to to one in the test-application, so that part seems to be good now. WineD3D does alter ARB shaders too, so I hope to find the issue sooner rather than later ;-)
__________________
Dxbx dev - Delphi FTW ;-) |
|
|
|
|
|
#40 | |||
|
Registered User
![]() ![]() ![]() Join Date: Jul 2010
Location: Caribbean
Posts: 353
|
Quote:
I noticed on the previous page that you had: Quote:
e.g. Code:
glMatrixMode(GL_PROJECTION); glOrtho (0,640,480,0,0,16777215); Quote:
Last edited by JohnJack; March 5th, 2011 at 18:50.. |
|||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|