Skip to main content
gamedev.net
🔒 Locked

D3D10 HLSL function parameters

Started by Vertex333 3 replies 1k views
Original Post
Vertex333
Vertex333
I started now with basic D3D10 HLSL and effect file programming. What I did: I wrote a VS that creates the vertices of a rectangle by using the vertexid and two global variables (topleft and bottomright points). This works pretty well. So, all vertices get calculated every frame by VS and not by CPU! (GS shouldn't perform well, buffers get allocated with the right size but not initialised) My problem: I can set function parameters... an yes I can set the parameters in the technique10/pass section where the function gets called/set. But setting the parameters does only allow me to set values instead of setting another variable or so. My question: What I want is to use a !NON GLOBAL! variable (constant would be possible) for only one function or pass or technique or whatever as long as it is not global and can be set outside the effect file. What else options do I have? I mean, setting it in the vertex data seems bad. Is it really that limited (new to shader programming) Thx, Vertex [Edited by - Vertex333 on October 16, 2008 8:12:47 AM]
jollyjeffers
jollyjeffers
So you want to pass parameters directly into the calls for individual vertices? That definitely isn't possible except through the routes you've already determined.

You can use:
  1. Per-vertex attributes, these can vary per vertex processed
  2. Other arbitrarily indexed (e.g. off SV_VertexID) from buffer loads or textures
  3. Per-primitive stepped values via instancing
  4. Constant buffers, can vary per draw call
  5. Techniques - hardcoded, can vary by as many techniques as you want to define
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Vertex333
Vertex333
Quote:
Original post by jollyjeffers
So you want to pass parameters directly into the calls for individual vertices? That definitely isn't possible except through the routes you've already determined.

You can use:
  1. Per-vertex attributes, these can vary per vertex processed
  2. Other arbitrarily indexed (e.g. off SV_VertexID) from buffer loads or textures
  3. Per-primitive stepped values via instancing
  4. Constant buffers, can vary per draw call
  5. Techniques - hardcoded, can vary by as many techniques as you want to define

Thx for conformation!
I am using constant buffers in combination with the vertexid.

But I still have a question about per-vertex attributes: Do I really need to specify or use the semantic and... do I have a limtitation of these, so I should not use it (e.g. color,position,...) for other stuff (e.g. additional calculation information).
Sc4Freak
Sc4Freak
No, semantics are arbitrary in D3D10. The only ones which are used by the system are ones which are prefixed with "SV_". Other than those, you can name your semantics whatever you want.
Vertex333
Vertex333
So I could use any kind of data (Let's say something that is needed inside VS) attached to vertex data(beside the position, color)?

Thx!
Vertex

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.