locked
Using ID3D11ClassLinkage::CreateClassInstance

    Question

  • I have pretty much the same question as this one 

    https://social.msdn.microsoft.com/Forums/windowshardware/en-US/0699d102-d1ce-4d31-9199-cfc61d860d0b/using-id3d11classlinkagecreateclassinstance-method?forum=wingameswithdirectx

    It was never answered though. Have consulted the msdn page for CreateClassInstance but with to no avail. 

    I've simplified my shader code for here, but I'm looking to instantiate one of the classes at run time

    Texture2D shaderTexture;
    SamplerState SampleType;

    RWTexture2D<float4> writeTex : register(u1);

    struct PixelInputType
    {
    float4
    float2 tex : TEXCOORD0;
    };

    i nterface iSplitPixels
    {
    float4 Split(PixelInputType input);
     };

    class SplitOdd : iSplitPixels
    {
    float4 Split(PixelInputType input){

    float4 temp = { 1, 0, 1, 1};
    return temp;
    }
    };

    class SplitEven : iSplitPixels
    {
    float4 Split(PixelInputType input){

    float4 temp = { 0, 1, 1, 1};
    return temp;
    }
    };

    iSplitPixels spliter;

    float4 Main(PixelInputType input) : SV_TARGET
    {
    float4 textureColor = {  1, 0, 0, 1.0f };

    writeTex[input.position.xy] = spliter.Split(input);

    return  textureColor;

    }

    and I'm using this code to do that:

    ID3D11ClassInstance* instance = nullptr;
    mShaders->GetPixelShader()->GetClassLinkage()->CreateClassInstance("SplitEven", 0, 0, 0, 0, &instance);

    mShaders->GetPixelShader()->GetDynamicLinkage()[0] = instance;

    The program compiles but does not render anything 

    Anyone got any ideas?

                        
    Wednesday, March 4, 2015 11:21 AM

Answers

  • Hello, Have you tried debugging your shader with the Vistual Studio 2013 graphics debugging tools (formerly PIX). You should be able to see the draw calls before and afer your shader to make sure you are getting the expected inputs. You should also be able to step into your shader and debugg it. You can find more information here: HLSL Debugger

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, March 5, 2015 11:39 PM
    Moderator

All replies

  • Hi AndimusPrime,

    I'm trying to find an engineer who is familiar with DirectX to help you :)

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 5, 2015 7:09 AM
    Moderator
  • Hello, Have you tried debugging your shader with the Vistual Studio 2013 graphics debugging tools (formerly PIX). You should be able to see the draw calls before and afer your shader to make sure you are getting the expected inputs. You should also be able to step into your shader and debugg it. You can find more information here: HLSL Debugger

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, March 5, 2015 11:39 PM
    Moderator