private static T GetShaderInstances <T>(CommonShaderStage <T> shader, out ClassInstance[] instances) where T : DeviceChild { var tempInstances = new ClassInstance[256]; var ret = shader.Get(tempInstances); int count; for (count = 0; count < 256; count++) { if (tempInstances[count] == null) { break; } } if (count == 0) { instances = null; } else { instances = new ClassInstance[count]; Array.Copy(tempInstances, 0, instances, 0, count); } return(ret); }
public void Apply(CommonShaderStage stage) { standardSamplers.Apply(stage); stage.SetConstantBuffer(ShaderSlots.EnvironmentParameters, constantBufferManager.Buffer); stage.SetShaderResource(ShaderSlots.DiffuseEnvironmentCube, diffuseEnvironmentCube); stage.SetShaderResource(ShaderSlots.GlossyEnvironmentCube, glossyEnvironmentCube); }
private void SetSampler(CommonShaderStage stage, ShaderStageCache cache, int slot, SamplerState sampler) { if (cache.Samplers[slot] != sampler) { stage.SetSampler(slot, sampler); cache.Samplers[slot] = sampler; } }
private void SetConstantBuffer(CommonShaderStage stage, ShaderStageCache cache, int slot, Buffer buffer) { if (cache.Buffers[slot] != buffer) { stage.SetConstantBuffer(slot, buffer); cache.Buffers[slot] = buffer; } }
private void SetTexture(CommonShaderStage stage, ShaderStageCache cache, int slot, ShaderResourceView view) { if (cache.Views[slot] != view) { // um Ressourcen Hazards zu vermeiden (Read und Write gleichzeitig) werden die RTs schon beim Setzen von Texturen neu gesetzt ApplyRenderTargets(); stage.SetShaderResource(slot, view); cache.Views[slot] = view; } }
public ConstantBuffer(Device device, DeviceContext deviceContext, CommonShaderStage commonShaderStage, int subresource, int slot) { _deviceContext = deviceContext; _buffer = new Buffer11( device, Utilities.SizeOf <T>(), ResourceUsage.Dynamic, BindFlags.ConstantBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0); _commonShaderStage = commonShaderStage; _subresource = subresource; _slot = slot; }
/// <summary> /// Creates instance of sampler state collection. /// </summary> /// <param name="device"></param> internal SamplerStateCollection(GraphicsDevice device, CommonShaderStage stage) : base(device) { states = new SamplerState[Count]; this.stage = stage; deviceContext = device.DeviceContext; }
public PerObjectConstantBuffer(Device device, DeviceContext deviceContext, CommonShaderStage commonShaderStage, int subresource, int slot) : base(device, deviceContext, commonShaderStage, subresource, slot) { }
/// <summary> /// /// </summary> /// <param name="device"></param> internal ShaderResourceCollection(GraphicsDevice device, CommonShaderStage stage) : base(device) { resources = new ShaderResource[Count]; this.stage = stage; }
public static void SetConstantBufferToNextSlot(this CommonShaderStage shader, SharpDX.Direct3D11.Buffer constantBuffer, ConstantBufferSlotsCache cache) { var slot = cache.GetNext(); shader.SetConstantBuffer(slot, constantBuffer); }
public static void SetConstantBuffer(this CommonShaderStage shader, int slot, SharpDX.Direct3D11.Buffer constantBuffer, ConstantBufferSlotsCache cache) { cache.SetOccupied(slot); shader.SetConstantBuffer(slot, constantBuffer); }
internal void Init(DeviceContext context, CommonShaderStage shaderStage, MyRenderContextStatistics statistics) { m_deviceContext = context; m_shaderStage = shaderStage; m_statistics = statistics; }
/// <summary> /// Creates instance of sampler state collection. /// </summary> /// <param name="device"></param> internal ConstantBufferCollection(GraphicsDevice device, CommonShaderStage stage) : base(device) { buffers = new ConstantBuffer[Count]; this.stage = stage; }
public void Apply(CommonShaderStage stage) { stage.SetSamplers(0, samplers); }
public void RegisterConstantBuffer(CommonShaderStage stage, int slot, DisposableSetter <SharpDX.Direct3D11.Buffer> buff) { RegisterConstantBuffer(stage, slot, buff.Get()); }
public void RegisterConstantBuffer(CommonShaderStage stage, int slot, SharpDX.Direct3D11.Buffer buff) { stage.SetConstantBuffer(slot, buff); resourseHash.RegisterResourseSlot(stage.GetHashCode(), slot); }