Original Post
Hello,
I registered to post this problem I have with Direct3D 10 concerning Render Targets.
I am building a small Fluid Simulator to get me started with DirectX 10.
I've been looking for a solution on the web for quite some time now to find the answer to my problem without too much success.
My problem can be easily explained, I guess.
You see, I have this method that runs given shader technique and takes a number of fields
to pipe as inputs (HLSL 4, by the way). The result will be written to the render target specified. Easy enough.
However, the method should also ensure, that any input and output fields are removed from the technique
before returning. But that seems to be the issue as the Debug Device gives me the "slot x is bound as output - forcing to NULL" warning for all input fields.
Obviously, I need to somehow unbind the render target here. But how exactly do I do that?
OMSetRenderTarget(0, NULL, NULL) does not suffice, as you can see:
Any help on how to make this work would be appreciated.
I registered to post this problem I have with Direct3D 10 concerning Render Targets.
I am building a small Fluid Simulator to get me started with DirectX 10.
I've been looking for a solution on the web for quite some time now to find the answer to my problem without too much success.
My problem can be easily explained, I guess.
You see, I have this method that runs given shader technique and takes a number of fields
to pipe as inputs (HLSL 4, by the way). The result will be written to the render target specified. Easy enough.
However, the method should also ensure, that any input and output fields are removed from the technique
before returning. But that seems to be the issue as the Debug Device gives me the "slot x is bound as output - forcing to NULL" warning for all input fields.
Obviously, I need to somehow unbind the render target here. But how exactly do I do that?
OMSetRenderTarget(0, NULL, NULL) does not suffice, as you can see:
typedef struct
{
ID3D10Texture2D *p_rt;
ID3D10RenderTargetView* p_rtv;
ID3D10ShaderResourceView *p_srv;
void BindField() { pD3DDevice->OMSetRenderTargets(1, &p_rtv, NULL); }
void UnbindField() { pD3DDevice->OMGetRenderTargets(0, NULL, NULL);}
void BindResource(ID3D10EffectShaderResourceVariable* p) { p->SetResource(p_srv); }
void Release() { SAFE_RELEASE(p_rt); SAFE_RELEASE(p_rtv); SAFE_RELEASE(p_srv); }
} Field;void RunShader(LPCSTR technique, Field *pInField0, Field *pInField1, Field *pInField2,
Field *pInField3, Field *pInField4, Field *pInField5, Field *pOutField)
{
D3D10_TECHNIQUE_DESC techniqueDescription;
gQuad.pTechnique = gQuad.pEffect->GetTechniqueByName(technique);
gQuad.pTechnique->GetDesc(&techniqueDescription);
gQuad.pTechnique->GetPassByIndex(0)->Apply(0);
//set the output-field to be the render target
if (pOutField != NULL) pOutField->BindField();
//and send input-fields down the pipe
if (pInField0 != NULL) pInField0->BindResource(pInput0);
if (pInField1 != NULL) pInField1->BindResource(pInput1);
if (pInField2 != NULL) pInField2->BindResource(pInput2);
if (pInField3 != NULL) pInField3->BindResource(pInput3);
if (pInField4 != NULL) pInField2->BindResource(pInput4);
if (pInField5 != NULL) pInField3->BindResource(pInput5);
for(UINT i = 0; i < techniqueDescription.Passes; i++)
{
gQuad.pTechnique->GetPassByIndex(i)->Apply(0);
pD3DDevice->Draw(gQuad.numVertices, 0);
}
//if (pOutField != NULL) pOutField->UnbindField();
pD3DDevice->OMSetRenderTargets(0, NULL, NULL);
pD3DDevice->OMSetRenderTargets(1, &pRenderTargetView, NULL);
//the following works ok
pInput0->SetResource(NULL); //<- ID3D10EffectShaderResourceVariable*
pInput1->SetResource(NULL);
pInput2->SetResource(NULL);
pInput3->SetResource(NULL);
pInput4->SetResource(NULL);
pInput5->SetResource(NULL);
gQuad.pTechnique->GetPassByIndex(0)->Apply(0);
}Any help on how to make this work would be appreciated.