Jump to content
  • Advertisement
Sign in to follow this  

[Slimdx] Question About Setting Constant Buffers

This topic is 786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ignore this:  Issue solved.   I found the function under device.ImmediateContext.VertexShader.SetConstantBuffer      

Apparently VertexShader declared in DeviceContext is actually a VertexWrapperClass.. not a VertexShaderClass which was confusing me.

Just posting the answer in case someone else has the same problem.



Too long didn't read:  I'm trying to find the SlimDX version of this line:

deviceContext->VSSetConstantBuffers(0, 1, &m_vertexPerObjectBuffer);

Trying to learn SlimDX and converting a C++ project I built into SlimDX.   I'm running into trouble on how to actually set a Constant Buffer.   I have managed to Create the Buffers, and update them like so: 

            vertexPerObject = new Buffer(device, new BufferDescription
                Usage = ResourceUsage.Default,
                SizeInBytes = Utility.SizeOf<VertexPerObject>(),
                BindFlags = BindFlags.ConstantBuffer
            var data = new DataStream(Utility.SizeOf<VertexPerObject>(), true, true);
            Matrix worldViewProj = Matrix.Multiply(worldMatrix, viewMatrix);
            worldViewProj = Matrix.Multiply(worldViewProj, projectionMatrix);

            data.Position = 0;
            device.ImmediateContext.UpdateSubresource(new DataBox(0, 0, data), vertexPerObject, 0);

However, the only source of setting a Constant Buffer I can find in the SlimDX library occurs in the VertexShaderWrapper class.   Here is the definition intellisense gives me on a peek:

public class VertexShaderWrapper
        public VertexShader Get();
        public VertexShader Get(ClassInstance[] classInstances);
        public Buffer[] GetConstantBuffers(int startSlot, int count);
        public SamplerState[] GetSamplers(int startSlot, int count);
        public ShaderResourceView[] GetShaderResources(int startSlot, int count);
        public void Set(VertexShader shader);
        public void Set(VertexShader shader, ClassInstance[] classInstances);
        public void SetConstantBuffer(Buffer constantBuffer, int slot);
        public void SetConstantBuffers(Buffer[] constantBuffers, int startSlot, int count);
        public void SetSampler(SamplerState sampler, int slot);
        public void SetSamplers(SamplerState[] samplers, int startSlot, int count);
        public void SetShaderResource(ShaderResourceView resourceView, int slot);
        public void SetShaderResources(ShaderResourceView[] resourceViews, int startSlot, int count);

I assume this means it has an Abstract Contructor that takes 0 arguments since its not static.  but trying this:

VertexShaderWrapper vsw = new VertexShaderWrapper();

Just gives me the error:   VertexShaderWrapper does not contain a Constructor that takes 0 arguments. 

Edited by drwhat

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!