locked
Passing an array to fragment shader for Direct2D custom effect, how do I use packoffset?

    Question

  • I want to create a custom Direct2D effect and I was looking into the following example...

    http://code.msdn.microsoft.com/windowsapps/Direct2D-custom-image-7a1f2cb5

    I see the following lines for passing parameters to the shader...

    Texture2D InputTexture : register(t0);
    SamplerState InputSampler : register(s0);
    cbuffer constants : register(b0)
    {
        float frequency : packoffset(c0.x);
        float phase     : packoffset(c0.y);
        float amplitude : packoffset(c0.z);
        float spread    : packoffset(c0.w);
        float2 center   : packoffset(c1);
    };

     

    I do not understand the packoffset and how to use the registers (c0, c1 etc.) and I could not find any reference as well on the internet.

    My requirement is such that I need to pass 4 byte arrays each of size 256. How do I do that, if at all possible? Something like...

    Texture2D InputTexture : register(t0);
    SamplerState InputSampler : register(s0);
    cbuffer constants : register(b0)
    {
        byte set1[256] : packoffset(c0);
        byte set2[256] : packoffset(c?);
        byte set3[256] : packoffset(c?);
        byte set4[256] : packoffset(c?);
    };

    Which registers shall I use?

    Sunday, July 29, 2012 9:07 AM

Answers

All replies

  • Ok, seems like I cannot use more than 31 constant registers. How do I pass some large data like this? Can I use some dummy texture etc?
    Sunday, July 29, 2012 11:23 AM
  • I think you can use texture for any data.

    C++ DX11

    Monday, July 30, 2012 12:03 PM
  • Thanks, I will try textures.
    Tuesday, July 31, 2012 8:48 AM