Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    Resource binding

    Advanced Programmer

    When drawing vertices using an effect, the shaders expect certain resources to be available, including:

    • textures and buffers
    • samplers
    • constant buffers

    Automatic resource binding

    The EffectInstance class handles the details of enumerating these resources from a loaded effect as well as binding them.

    It exposes the RootSignature, which has to be set as pipeline state, and allows to fill constant buffers and bind resources based on a ParameterCollection.

    Code: Using an EffectInstance

    // Create a EffectInstance and use it to set up the pipeline
    var effectInstance = new EffectInstance(EffectSystem.LoadEffect("MyEffect").WaitForResult());
    pipelineStateDescription.EffectBytecode = effectInstance.Effect.Bytecode;
    pipelineStateDescription.RootSignature = effectInstance.RootSignature;
    
    // Update constant buffers and bind resources
    effectInstance.Apply(context.GraphicsContext);
    

    Manual resource binding

    When more optimized code is required (eg in the rendering pipeline), constant buffer updates and resource binding can be done manually.

    • Improve this Doc
    In This Article
    In This Article
    • Automatic resource binding
    • Manual resource binding

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation