本文整理汇总了C#中SharpDX.Direct3D11.UnorderedAccessView类的典型用法代码示例。如果您正苦于以下问题:C# UnorderedAccessView类的具体用法?C# UnorderedAccessView怎么用?C# UnorderedAccessView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnorderedAccessView类属于SharpDX.Direct3D11命名空间,在下文中一共展示了UnorderedAccessView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VolumeRWTexture
/// <summary>
/// Creates texture
/// </summary>
/// <param name="device"></param>
public VolumeRWTexture ( GraphicsDevice device, int width, int height, int depth, ColorFormat format, bool mips ) : base( device )
{
this.Width = width;
this.Height = height;
this.Depth = depth;
this.format = format;
this.mipCount = mips ? ShaderResource.CalculateMipLevels(Width,Height,Depth) : 1;
var texDesc = new Texture3DDescription();
texDesc.BindFlags = BindFlags.ShaderResource | BindFlags.UnorderedAccess;
texDesc.CpuAccessFlags = CpuAccessFlags.None;
texDesc.Format = Converter.Convert( format );
texDesc.Height = Height;
texDesc.MipLevels = mipCount;
texDesc.OptionFlags = ResourceOptionFlags.None;
texDesc.Usage = ResourceUsage.Default;
texDesc.Width = Width;
texDesc.Depth = Depth;
var uavDesc = new UnorderedAccessViewDescription();
uavDesc.Format = Converter.Convert( format );
uavDesc.Dimension = UnorderedAccessViewDimension.Texture3D;
uavDesc.Texture3D.FirstWSlice = 0;
uavDesc.Texture3D.MipSlice = 0;
uavDesc.Texture3D.WSize = depth;
tex3D = new D3D.Texture3D( device.Device, texDesc );
SRV = new D3D.ShaderResourceView( device.Device, tex3D );
uav = new UnorderedAccessView( device.Device, tex3D, uavDesc );
}
示例2: SetViewsToResources
/// <summary>
/// Bind all the sub resources to view
/// </summary>
/// <param name="view"></param>
public void SetViewsToResources(UnorderedAccessView view)
{
// bind all the sub-resources with the same view
foreach (var resource in ListWithResourceVariables)
{
resource.resource.SetResource(view);
}
}
示例3: ConvolutionEngine
/// <summary>
/// Creates a ConvolutionEngine instance.
/// </summary>
/// <param name="device">The graphics device to use.</param>
/// <param name="context">The graphics context to use.</param>
/// <param name="resolution">The convolution resolution.</param>
public ConvolutionEngine(Device device, DeviceContext context, Size resolution)
{
fft = FastFourierTransform.Create2DComplex(context, resolution.Width, resolution.Height);
fft.InverseScale = 1.0f / (float)(resolution.Width * resolution.Height);
this.resolution = resolution;
FastFourierTransformBufferRequirements bufferReqs = fft.BufferRequirements;
precomputed = new FFTBuffer[bufferReqs.PrecomputeBufferCount];
temporaries = new FFTBuffer[bufferReqs.TemporaryBufferCount];
for (int t = 0; t < precomputed.Length; ++t)
precomputed[t] = FFTUtils.AllocateBuffer(device, bufferReqs.PrecomputeBufferSizes[t]);
for (int t = 0; t < temporaries.Length; ++t)
temporaries[t] = FFTUtils.AllocateBuffer(device, bufferReqs.TemporaryBufferSizes[t]);
UnorderedAccessView[] precomputedUAV = new UnorderedAccessView[bufferReqs.PrecomputeBufferCount];
for (int t = 0; t < precomputed.Length; ++t) precomputedUAV[t] = precomputed[t].view;
UnorderedAccessView[] temporariesUAV = new UnorderedAccessView[bufferReqs.TemporaryBufferCount];
for (int t = 0; t < temporaries.Length; ++t) temporariesUAV[t] = temporaries[t].view;
fft.AttachBuffersAndPrecompute(temporariesUAV, precomputedUAV);
lBuf = FFTUtils.AllocateBuffer(device, 2 * resolution.Width * resolution.Height);
rBuf = FFTUtils.AllocateBuffer(device, 2 * resolution.Width * resolution.Height);
tBuf = FFTUtils.AllocateBuffer(device, 2 * resolution.Width * resolution.Height);
rConvolved = new GraphicsResource(device, resolution, Format.R32_Float, true, true);
gConvolved = new GraphicsResource(device, resolution, Format.R32_Float, true, true);
bConvolved = new GraphicsResource(device, resolution, Format.R32_Float, true, true);
staging = new GraphicsResource(device, new Size(resolution.Width / 2, resolution.Height / 2), Format.R32G32B32A32_Float, true, true);
BlendStateDescription description = new BlendStateDescription()
{
AlphaToCoverageEnable = false,
IndependentBlendEnable = false,
};
description.RenderTarget[0] = new RenderTargetBlendDescription()
{
IsBlendEnabled = true,
SourceBlend = BlendOption.One,
DestinationBlend = BlendOption.One,
BlendOperation = BlendOperation.Add,
SourceAlphaBlend = BlendOption.Zero,
DestinationAlphaBlend = BlendOption.Zero,
AlphaBlendOperation = BlendOperation.Add,
RenderTargetWriteMask = ColorWriteMaskFlags.Red
| ColorWriteMaskFlags.Green
| ColorWriteMaskFlags.Blue,
};
blendState = new BlendState(device, description);
}
示例4: AppendPointCloudBuffer
/// <summary>
/// Constructor
/// </summary>
/// <param name="device">Direct3D11 Device</param>
public AppendPointCloudBuffer(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.buffer = new SharpDX.Direct3D11.Buffer(device, PointCloudDescriptors.PositionBuffer);
this.shaderView = new ShaderResourceView(device, this.buffer);
this.unorderedView = new UnorderedAccessView(device, this.buffer, PointCloudDescriptors.AppendView);
}
示例5: RenderTargetSurface
/// <summary>
///
/// </summary>
/// <param name="rtv"></param>
internal RenderTargetSurface( RenderTargetView rtv, UnorderedAccessView uav, Resource resource, int subresource, ColorFormat format, int width, int height, int sampleCount )
{
Width = width;
Height = height;
Format = format;
SampleCount = sampleCount;
RTV = rtv;
UAV = uav;
Resource = resource;
Subresource = subresource;
}
示例6: SetTargets
/// <summary>
/// Binds a set of unordered access views and a set of render targets to the output-merger stage.
/// </summary>
/// <param name = "startSlot">Index into a zero-based array to begin setting unordered access views.</param>
/// <param name = "unorderedAccessViews">A set of unordered access views to bind.</param>
/// <param name = "renderTargetViews">A set of render target views to bind.</param>
/// <param name = "initialLengths">An array of Append/Consume buffer offsets. A value of -1 indicates the current offset should be kept. Any other values set the hidden counter for that Appendable/Consumable UAV.</param>
/// <msdn-id>ff476465</msdn-id>
/// <unmanaged>void ID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews([In] unsigned int NumRTVs,[In, Buffer, Optional] const ID3D11RenderTargetView** ppRenderTargetViews,[In, Optional] ID3D11DepthStencilView* pDepthStencilView,[In] unsigned int UAVStartSlot,[In] unsigned int NumUAVs,[In, Buffer, Optional] const ID3D11UnorderedAccessView** ppUnorderedAccessViews,[In, Buffer, Optional] const unsigned int* pUAVInitialCounts)</unmanaged>
/// <unmanaged-short>ID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews</unmanaged-short>
public void SetTargets(
int startSlot,
UnorderedAccessView[] unorderedAccessViews,
int[] initialLengths,
params RenderTargetView[] renderTargetViews)
{
SetTargets(null, startSlot, unorderedAccessViews, initialLengths, renderTargetViews);
}
示例7: GetUnorderedAccessView
internal override UnorderedAccessView GetUnorderedAccessView(int zSlice, int mipIndex)
{
if ((this.Description.BindFlags & BindFlags.UnorderedAccess) == 0)
return null;
int sliceCount = 1;
// Use Full although we are binding to a single array/mimap slice, just to get the correct index
var uavIndex = GetViewIndex(ViewType.Full, zSlice, mipIndex);
lock (this.unorderedAccessViews)
{
var uav = this.unorderedAccessViews[uavIndex];
// Creates the unordered access view
if (uav == null)
{
var uavDescription = new UnorderedAccessViewDescription() {
Format = this.Description.Format,
Dimension = UnorderedAccessViewDimension.Texture3D,
Texture3D = {
FirstWSlice = zSlice,
MipSlice = mipIndex,
WSize = sliceCount
}
};
uav = new UnorderedAccessView(GraphicsDevice, Resource, uavDescription) { Tag = this };
this.unorderedAccessViews[uavIndex] = ToDispose(uav);
}
return uav;
}
}
示例8: GetUnorderedAccessViews
/// <summary>
/// Gets an array of views for an unordered resource.
/// </summary>
/// <remarks>
/// Any returned interfaces will have their reference count incremented by one. Applications should call IUnknown::Release on the returned interfaces when they are no longer needed to avoid memory leaks.
/// </remarks>
/// <param name="startSlot">Index of the first element in the zero-based array to return (ranges from 0 to D3D11_PS_CS_UAV_REGISTER_COUNT - 1). </param>
/// <param name="count">Number of views to get (ranges from 0 to D3D11_PS_CS_UAV_REGISTER_COUNT - StartSlot). </param>
/// <unmanaged>void OMGetRenderTargetsAndUnorderedAccessViews([In] int NumRTVs,[Out, Buffer, Optional] ID3D11RenderTargetView** ppRenderTargetViews,[Out, Optional] ID3D11DepthStencilView** ppDepthStencilView,[In] int UAVStartSlot,[In] int NumUAVs,[Out, Buffer, Optional] ID3D11UnorderedAccessView** ppUnorderedAccessViews)</unmanaged>
public UnorderedAccessView[] GetUnorderedAccessViews(int startSlot, int count)
{
var temp = new UnorderedAccessView[count];
DepthStencilView depthStencilView;
GetRenderTargetsAndUnorderedAccessViews(0, new RenderTargetView[0], out depthStencilView, startSlot, count, temp);
depthStencilView.Dispose();
return temp;
}
示例9: SetUAVs
public void SetUAVs(UnorderedAccessView first, UnorderedAccessView second)
{
UAVs[0] = first;
UAVs[1] = second;
}
示例10: BindUAV
internal void BindUAV(int slot, params MyBindableResource[] UAVs)
{
var buffer = new UnorderedAccessView[UAVs.Length];
for (int i = 0; i < UAVs.Length; i++)
{
if (UAVs[i] != null)
{
var ua = UAVs[i] as IUnorderedAccessBindable;
Debug.Assert(ua != null);
UnbindSRVRead(UAVs[i].GetID());
//UnbindDSVReadOnly(UAVs[i].ResId); necessary?
int? currentlyBound = null;
foreach (var kv in State.m_bindings)
{
if (kv.Value.UavSlot == slot + i)
{
currentlyBound = kv.Key;
break;
}
}
if (currentlyBound.HasValue)
{
State.m_bindings.Remove(currentlyBound.Value);
}
State.m_bindings[UAVs[i].GetID()] = new MyBinding(MyWriteBindingEnum.UAV, slot + i);
buffer[i] = ua.UAV;
}
}
Context.ComputeShader.SetUnorderedAccessViews(slot, buffer);
}
示例11: GetUnorderedAccessView
internal override UnorderedAccessView GetUnorderedAccessView(int arrayOrDepthSlice, int mipIndex)
{
if ((this.Description.BindFlags & BindFlags.UnorderedAccess) == 0)
return null;
int arrayCount = 1;
// Use Full although we are binding to a single array/mimap slice, just to get the correct index
var uavIndex = GetViewIndex(ViewType.Full, arrayOrDepthSlice, mipIndex);
lock (this.unorderedAccessViews)
{
var uav = this.unorderedAccessViews[uavIndex];
// Creates the unordered access view
if (uav == null)
{
var uavDescription = new UnorderedAccessViewDescription() {
Format = this.Description.Format,
Dimension = this.Description.ArraySize > 1 ? UnorderedAccessViewDimension.Texture1DArray : UnorderedAccessViewDimension.Texture1D
};
if (this.Description.ArraySize > 1)
{
uavDescription.Texture1DArray.ArraySize = arrayCount;
uavDescription.Texture1DArray.FirstArraySlice = arrayOrDepthSlice;
uavDescription.Texture1DArray.MipSlice = mipIndex;
}
else
{
uavDescription.Texture1D.MipSlice = mipIndex;
}
uav = new UnorderedAccessView(GraphicsDevice, Resource, uavDescription);
this.unorderedAccessViews[uavIndex] = ToDispose(uav);
}
// Associate this instance
uav.Tag = this;
return uav;
}
}
示例12: MyUnorderedAccessTexture
internal MyUnorderedAccessTexture(int width, int height, Format format)
{
m_resolution = new Vector2I(width, height);
Texture2DDescription desc = new Texture2DDescription();
desc.Width = width;
desc.Height = height;
desc.Format = format;
desc.ArraySize = 1;
desc.MipLevels = 1;
desc.BindFlags = BindFlags.UnorderedAccess | BindFlags.ShaderResource | BindFlags.RenderTarget;
desc.Usage = ResourceUsage.Default;
desc.CpuAccessFlags = 0;
desc.SampleDescription.Count = 1;
desc.SampleDescription.Quality = 0;
desc.OptionFlags = 0;
m_resource = new Texture2D(MyRender11.Device, desc);
m_UAV = new UnorderedAccessView(MyRender11.Device, m_resource);
m_SRV = new ShaderResourceView(MyRender11.Device, m_resource);
m_RTV = new RenderTargetView(MyRender11.Device, m_resource);
}
示例13: MyIndirectArgsBuffer
internal MyIndirectArgsBuffer(int elements, int stride, string debugName)
{
m_resolution = new Vector2I(elements, 1);
var bufferDesc = new BufferDescription(elements * stride, ResourceUsage.Default, BindFlags.UnorderedAccess,
CpuAccessFlags.None, ResourceOptionFlags.DrawIndirectArguments, stride);
m_resource = new SharpDX.Direct3D11.Buffer(MyRender11.Device, bufferDesc);
m_resource.DebugName = debugName;
var description = new UnorderedAccessViewDescription()
{
Buffer = new UnorderedAccessViewDescription.BufferResource()
{
ElementCount = elements,
FirstElement = 0,
Flags = 0
},
Format = Format.R32_UInt,
Dimension = UnorderedAccessViewDimension.Buffer
};
m_uav = new UnorderedAccessView(MyRender11.Device, m_resource, description);
m_uav.DebugName = debugName + "Uav";
}
示例14: UpdateCS
private void UpdateCS(string name, UnorderedAccessView append, UnorderedAccessView consume)
{
int width, height;
height = 1;
width = this.Constants.MaxParticles;
var context = this.DeviceManager.Direct3DContext;
// Compile the shader if it isn't already
if (!computeShaders.ContainsKey(name))
{
CompileComputeShader(name);
}
// Set the shader to run
context.ComputeShader.Set(computeShaders[name]);
//DebugCount("Update-consume-1", context, consume);
clock.Restart();
// Dispatch the compute shader thread groups
context.Dispatch((int)Math.Ceiling(width / (double)ThreadsX), (int)Math.Ceiling(height / (double)ThreadsY), 1);
LastDispatchTicks = clock.ElapsedTicks;
//DebugCount("Update-consume-2", context, consume);
}
示例15: GenerateCS
private void GenerateCS(string name, UnorderedAccessView append)
{
var context = this.DeviceManager.Direct3DContext;
// Compile the shader if it isn't already
if (!computeShaders.ContainsKey(name))
{
int oldThreadsX = ThreadsX;
int oldThreadsY = ThreadsY;
ThreadsX = GeneratorThreadsX;
ThreadsY = 1;
CompileComputeShader(name);
ThreadsX = oldThreadsX;
ThreadsY = oldThreadsY;
}
// Set the shader to run
context.ComputeShader.Set(computeShaders[name]);
clock.Restart();
// Dispatch the compute shader thread groups
context.Dispatch((int)Math.Ceiling(ParticlesPerBatch / 16.0), 1, 1);
LastDispatchTicks = clock.ElapsedTicks;
DebugCount("Gen-append", context, append);
}