Jump to content

  • Log In with Google      Sign In   
  • Create Account


Dynamic shader linkage : class from other shader/file


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Juliean   GDNet+   -  Reputation: 1928

Like
0Likes
Like

Posted 19 September 2013 - 08:03 AM

Hello,

 

in a thread a while ago, I asked about a way of dynamically altering the implementation of shader: shader "plugin" system. I was told to use dynamic shader linkage, and since I've now seperated all my modules into dll plugins, I've finally decided to implement it. I expected it to work like this:

 

// file Ambient.fx

interface IAmbient
{
	float AmbientTerm(float2 vTex);
};

IAmbient iAmbient;

float4 mainPS(VS_OUTPUT i) : SV_Target0
{
	return iAmbient.AmbientTerm(i.vTex0);
};

// file SSAO.fx

class SSAO: IAmbient
{
	float AmbientTerm(float2 vTex)
        {
               // calc & return... ssao term
        }
};

SSAO cSSAO;

Then I thought I could just get the SSAO-declaration using ID3D11ClassLinkage::GetClassInstance and set it as input to the PSSetShader()-method when applying the ambient pixel shader.

 

However, I get

 

- an error when I don't at least derive one class from the interface in the very shader that declares it.

- a 0 as return value when using ID3D11ShaderReflection::GetNumInterfaceSlots (appearently you need to derive at least two different classes from he interface in the same shader file, for the interface to be usable).

 

This leads me to belive that what I want to achieve is not double in the way I tried. Does anyone know if there is any way to "inject" an interface implementation after the shader has been compiled, without needing to have to declare two classes from the interface myself in the same shader?



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS