4 using SiliconStudio.Paradox.Graphics;
5 using SiliconStudio.Core;
6 using SiliconStudio.Paradox.Shaders;
8 namespace SiliconStudio.
Paradox.Graphics.Internals
12 ConstantBufferData[] constantBufferDatas;
16 private bool forceDataChanged =
false;
18 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGL
19 private static readonly
bool UsingMap =
false;
21 private static readonly
bool UsingMap =
true;
26 ConstantBufferDesc = constantBufferDesc;
27 constantBufferDatas =
new ConstantBufferData[GraphicsDevice.ThreadCount];
28 dataStreams =
new DataPointer[GraphicsDevice.ThreadCount];
30 for (uint i = 0; i < GraphicsDevice.ThreadCount; ++i)
32 constantBufferDatas[i] =
new ConstantBufferData(constantBufferDesc);
33 dataStreams[i] =
new DataPointer(constantBufferDatas[i].Data, constantBufferDesc.
Size);
36 Buffer = SiliconStudio.Paradox.Graphics.Buffer.New(device, constantBufferDatas[0].Desc.Size,
BufferFlags.ConstantBuffer, UsingMap ? GraphicsResourceUsage.Dynamic : GraphicsResourceUsage.Default);
40 Buffer.Reload = Reload;
45 forceDataChanged =
true;
48 graphicsResourceBase.OnRecreate();
51 public void Update(
GraphicsDevice graphicsDevice, ShaderParameterUpdater parameterUpdater)
53 var threadIndex = graphicsDevice.ThreadIndex;
54 bool dataChanged = constantBufferDatas[threadIndex].Update(parameterUpdater);
58 forceDataChanged =
false;
59 else if (!dataChanged)
63 Buffer.SetData(graphicsDevice, dataStreams[threadIndex]);
SiliconStudio.Shaders.Ast.Hlsl.ConstantBuffer ConstantBuffer
int Size
The size in bytes.
Description of a constant buffer.
Base class for a framework component.
All-in-One Buffer class linked SharpDX.Direct3D11.Buffer.
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.