// Get the D3D resource locations for parameters
// This can be done earlier and saved
DWORD vsReg = cgGetParameterResourceIndex(vsModelView);
DWORD stage = cgGetParameterResourceIndex(psBaseTexture);
DWORD psReg = cgGetParameterResourceIndex(psColor);
// Set the D3D state
pDev->SetVertexShaderConstantF(vsReg, &mv, 4);
pDev->SetPixelShaderConstantF(psReg, &color, 1);
nvidia cg runtime question
Howdy,
I am using the cg runtime + direct3d9
the issue is this: cgD3D9SetUniform() and cgD3D9SetUniformArray() only accept float values, but i am planning to have the values stored in a more felxible way, float, ints ... (is that bad?)
so to set values that are not floats as shader constants i will have to bypass
cgD3D9SetUniform() and use the interface minimally,
the cg reference manual (1.4.1) suggests:
this is all nice, but can i also use SetVertexShaderConstantB or SetVertexShaderConstantI after getting the register index with cgGetParameterResourceIndex?
AND how do i handle offsets the way cgD3D9SetUniformArray() handles them?
can i use the parameter sizes to determin register offsets?
if a cg struct like this
{
float3 dummy[16];
}
returns a cgGetParameterResourceIndex() of lets say 0, can i then say that the register index for dummy[1] is 0 + sizeof(float3) ? I guess not? then my problem is how do i implement functionality that can use offset values like cgD3D9SetUniformArray ?
i think i figured it out, i should iterate thru the leaf parameters and use cgD3D9TypeToSize ? will that work?
and one more question: is cgGetParameterResourceIndex 'fast enough' to be used at run time or is tit better to cache its result?
[Edited by - PinkFish on September 23, 2006 1:28:56 PM]
and one more question: is cgGetParameterResourceIndex 'fast enough' to be used at run time or is tit better to cache its result?
[Edited by - PinkFish on September 23, 2006 1:28:56 PM]
You could always use the "generic" parameter setter functions defined in cg.h. Like cgSetParameter3f, etc...
These are actually recommended over the API specific setters like cgD3D9SetUniform.
These are actually recommended over the API specific setters like cgD3D9SetUniform.
Quote:Original post by SirKnight
You could always use the "generic" parameter setter functions defined in cg.h. Like cgSetParameter3f, etc...
These are actually recommended over the API specific setters like cgD3D9SetUniform.
Ah thx! i didnt know those would work, and since u mentioned it, how do they handle setting per exmaple only one float value?? since the underlying d3d9 functions dont take anything that is not a group of 4 floats, or?
So cgSetParameter1f would just take a zero-vector {0,0,0,0} and put the value in the x component {x,0,0,0} and send that to D3D.
ok so cgSetParameterValue isnt working for me
this doesnt work, the value (a simple color) isnt taken into account
produces no d3d warnings/errors in debug window,
now this, works like a charm!!
i didnt try cgD3D9SetUniform yet.
what should i do? am i using cgSetParameterValuefr the wrong way?
or is it a bug?
this doesnt work, the value (a simple color) isnt taken into account
produces no d3d warnings/errors in debug window,
//vf is a float[3]cgSetParameterValuefr(param, 1, vf);
now this, works like a charm!!
DWORD vsReg = cgGetParameterResourceIndex(param);float test[] = {fv[0], vf[1], vf[2], 0.0f};DWORD ret = pDev->SetVertexShaderConstantF(vsReg, test, 1);
i didnt try cgD3D9SetUniform yet.
what should i do? am i using cgSetParameterValuefr the wrong way?
or is it a bug?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement