本文整理汇总了C#中SharpDX.Direct3D11.ShaderResourceView类的典型用法代码示例。如果您正苦于以下问题:C# ShaderResourceView类的具体用法?C# ShaderResourceView怎么用?C# ShaderResourceView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShaderResourceView类属于SharpDX.Direct3D11命名空间,在下文中一共展示了ShaderResourceView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateDeviceDependentResources
protected override void CreateDeviceDependentResources()
{
RemoveAndDispose(ref vertexBuffer);
RemoveAndDispose(ref indexBuffer);
// Retrieve our SharpDX.Direct3D11.Device1 instance
var device = this.DeviceManager.Direct3DDevice;
// Load texture (a DDS cube map)
textureView = ShaderResourceView.FromFile(device, "CubeMap.dds");
// Create our sampler state
samplerState = new SamplerState(device, new SamplerStateDescription()
{
AddressU = TextureAddressMode.Clamp,
AddressV = TextureAddressMode.Clamp,
AddressW = TextureAddressMode.Clamp,
BorderColor = new Color4(0, 0, 0, 0),
ComparisonFunction = Comparison.Never,
Filter = Filter.MinMagMipLinear,
MaximumLod = 9, // Our cube map has 10 mip map levels (0-9)
MinimumLod = 0,
MipLodBias = 0.0f
});
Vertex[] vertices;
int[] indices;
GeometricPrimitives.GenerateSphere(out vertices, out indices, Color.Gray);
vertexBuffer = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, vertices));
vertexBinding = new VertexBufferBinding(vertexBuffer, Utilities.SizeOf<Vertex>(), 0);
indexBuffer = ToDispose(Buffer.Create(device, BindFlags.IndexBuffer, indices));
totalVertexCount = indices.Length;
}
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:35,代码来源:SphereRenderer.cs
示例2: Bitmap
public Bitmap(Device device, ShaderResourceView texture, Vector2I screenSize, Vector2I size, float depth = 0.0f)
{
Texture = texture;
ScreenSize = screenSize;
Size = size;
_changed = true;
Depth = depth;
VertexCount = 4;
IndexCount = 6;
_vertices = new TranslateShader.Vertex[VertexCount];
UInt32[] indices = {0, 1, 2, 0, 3, 1};
VertexBuffer = Buffer.Create(device, _vertices,
new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = Utilities.SizeOf<TranslateShader.Vertex>() * VertexCount,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
StructureByteStride = 0
});
IndexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices);
}
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:27,代码来源:Bitmap.cs
示例3: MyTextureArray
internal MyTextureArray(TexId[] mergeList)
{
var srcDesc = MyTextures.GetView(mergeList[0]).Description;
Size = MyTextures.GetSize(mergeList[0]);
ArrayLen = mergeList.Length;
Texture2DDescription desc = new Texture2DDescription();
desc.ArraySize = ArrayLen;
desc.BindFlags = BindFlags.ShaderResource;
desc.CpuAccessFlags = CpuAccessFlags.None;
desc.Format = srcDesc.Format;
desc.Height = (int)Size.Y;
desc.Width = (int)Size.X;
desc.MipLevels = 0;
desc.SampleDescription.Count = 1;
desc.SampleDescription.Quality = 0;
desc.Usage = ResourceUsage.Default;
m_resource = new Texture2D(MyRender11.Device, desc);
// foreach mip
var mipmaps = (int)Math.Log(Size.X, 2) + 1;
for (int a = 0; a < ArrayLen; a++)
{
for (int m = 0; m < mipmaps; m++)
{
MyRender11.Context.CopySubresourceRegion(MyTextures.Textures.Data[mergeList[a].Index].Resource, Resource.CalculateSubResourceIndex(m, 0, mipmaps), null, Resource,
Resource.CalculateSubResourceIndex(m, a, mipmaps));
}
}
ShaderView = new ShaderResourceView(MyRender11.Device, Resource);
}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:33,代码来源:MyResource.cs
示例4: RenderTexture
public RenderTexture(Device device, Vector2I screenSize)
{
var textureDesc = new Texture2DDescription()
{
Width = screenSize.X,
Height = screenSize.Y,
MipLevels = 1,
ArraySize = 1,
Format = Format.R32G32B32A32_Float,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None
};
_renderTargetTexture = new Texture2D(device, textureDesc);
_renderTargetView = new RenderTargetView(device, _renderTargetTexture,
new RenderTargetViewDescription
{
Format = textureDesc.Format,
Dimension = RenderTargetViewDimension.Texture2D,
Texture2D = {MipSlice = 0},
});
// Create the render target view.
ShaderResourceView = new ShaderResourceView(device, _renderTargetTexture,
new ShaderResourceViewDescription
{
Format = textureDesc.Format,
Dimension = ShaderResourceViewDimension.Texture2D,
Texture2D = { MipLevels = 1, MostDetailedMip = 0 },
});
}
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:35,代码来源:RenderTexture.cs
示例5: TextureCubeArray
/// <summary>
///
/// </summary>
/// <param name="device"></param>
/// <param name="size"></param>
/// <param name="count"></param>
/// <param name="format"></param>
/// <param name="mips"></param>
public TextureCubeArray ( GraphicsDevice device, int size, int count, ColorFormat format, bool mips ) : base(device)
{
if (count>2048/6) {
throw new GraphicsException("Too much elements in texture array");
}
this.Width = size;
this.Depth = 1;
this.Height = size;
this.MipCount = mips ? ShaderResource.CalculateMipLevels(Width,Height) : 1;
var texDesc = new Texture2DDescription();
texDesc.ArraySize = 6 * count;
texDesc.BindFlags = BindFlags.ShaderResource;
texDesc.CpuAccessFlags = CpuAccessFlags.None;
texDesc.Format = MakeTypeless( Converter.Convert( format ) );
texDesc.Height = Height;
texDesc.MipLevels = 0;
texDesc.OptionFlags = ResourceOptionFlags.TextureCube;
texDesc.SampleDescription.Count = 1;
texDesc.SampleDescription.Quality = 0;
texDesc.Usage = ResourceUsage.Default;
texDesc.Width = Width;
texCubeArray = new D3D.Texture2D( device.Device, texDesc );
SRV = new ShaderResourceView( device.Device, texCubeArray );
}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:37,代码来源:TextureCubeArray.cs
示例6: ShaderResource
/// <summary>
///
/// </summary>
/// <param name="device"></param>
internal protected ShaderResource( GraphicsDevice device, ShaderResourceView srv, int w, int h, int d ) : base(device)
{
this.SRV = srv;
this.Width = w;
this.Height = h;
this.Depth = d;
}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:11,代码来源:ShaderResource.cs
示例7: InitializeInternal
protected override void InitializeInternal()
{
var sourceTextures = _textures.Select(t =>
{
var view = t.ShaderResourceView;
if(view == null)
throw new InvalidOperationException(string.Format("Texture array cannot be created because source texture '{0}' is not initialized", t.Id));
return view.Resource.QueryInterface<Texture2D>();
}).ToArray();
var descr = sourceTextures[0].Description;
descr.ArraySize = _textures.Length;
_textureArray = new Texture2D(DeviceManager.Device, descr);
ShaderResourceView = new ShaderResourceView(DeviceManager.Device, _textureArray);
var mipLevels = descr.MipLevels;
for(var i = 0; i < mipLevels; i++)
{
for(var j = 0; j < _textures.Length; j++)
{
var texture = sourceTextures[j];
DeviceManager.Context.CopySubresourceRegion(texture, i, null, _textureArray, mipLevels * j + i);
}
}
}
开发者ID:gitter-badger,项目名称:Grasshopper,代码行数:25,代码来源:TextureArrayResource.cs
示例8: 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 );
}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:34,代码来源:VolumeRWTexture.cs
示例9: BodyCameraPositionBuffer
/// <summary>
/// Constructor
/// </summary>
/// <param name="device">Direct3D11 Device</param>
public BodyCameraPositionBuffer(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.buffer = new SharpDX.Direct3D11.Buffer(device, JointBufferDescriptor.CameraSpacePositionBuffer);
this.shaderView = new ShaderResourceView(device, this.buffer);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:12,代码来源:BodyCameraPositionBuffer.cs
示例10: DynamicColorRGBATexture
/// <summary>
/// Creates a dynamic color texture, allocates GPU resources
/// </summary>
/// <param name="device">Direct3D Device</param>
public DynamicColorRGBATexture(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.texture = new Texture2D(device, ColorTextureDescriptors.DynamicRGBAResource);
this.rawView = new ShaderResourceView(device,this.texture);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:12,代码来源:DynamicColorRGBATexture.cs
示例11: SetViewsToResources
/// <summary>
/// Bind all the sub resources to view
/// </summary>
/// <param name="view"></param>
public void SetViewsToResources(ShaderResourceView view)
{
// bind all the sub-resources with the same view
foreach (var resource in ListWithResourceVariables)
{
resource.resource.SetResource(view);
}
}
开发者ID:fxbit,项目名称:FxFramework,代码行数:12,代码来源:FxResourceVariableList.cs
示例12: Shape
public Shape(VertexBufferBinding vertexBinding, PrimitiveTopology topology, ShaderResourceView textureView, Style style, int vertexCount)
{
this.vertexBinding = vertexBinding;
this.topology = topology;
this.textureView = textureView;
this.style = style;
this.vertexCount = vertexCount;
}
开发者ID:philyum,项目名称:TheAmazingFishy,代码行数:8,代码来源:Shape.cs
示例13: DynamicDepthToColorTexture
/// <summary>
/// Constructor
/// </summary>
/// <param name="device">Direct3D11 Device</param>
public DynamicDepthToColorTexture(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.texture = new Texture2D(device, CoordinateMapTextureDescriptors.DynamicDepthToColor);
this.shaderView = new ShaderResourceView(device, this.texture);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:12,代码来源:DynamicDepthtoColorTexture.cs
示例14: DynamicLongExposureInfraredTexture
/// <summary>
/// Creates a dynamic depth texture, allocates GPU resources
/// </summary>
/// <param name="device">Direct3D Device</param>
public DynamicLongExposureInfraredTexture(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.texture = new Texture2D(device, InfraredTextureDescriptors.DynamicResource);
this.shaderView = new ShaderResourceView(device, this.texture);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:12,代码来源:DynamicLongExposureInfraredTexture.cs
示例15: BodyJointStatusBuffer
/// <summary>
/// Constructor
/// </summary>
/// <param name="device">Direct3D11 Device</param>
public BodyJointStatusBuffer(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.buffer = new SharpDX.Direct3D11.Buffer(device, JointBufferDescriptor.DynamicBuffer(new BufferStride(4)));
this.shaderView = new ShaderResourceView(device, this.buffer);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:12,代码来源:BodyJointStatusBuffer.cs
示例16: Render
public void Render(DeviceContext deviceContext, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix, ShaderResourceView texture)
{
int stride = Utilities.SizeOf<VertexDefinition.PositionTexture>(); //Gets or sets the stride between vertex elements in the buffer (in bytes).
deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(VertexBuffer, stride, 0));
deviceContext.InputAssembler.SetIndexBuffer(IndexBuffer, Format.R32_UInt, 0);
deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
_shader.Render(deviceContext, IndexCount, worldMatrix, viewMatrix, projectionMatrix, texture ?? _texture);
}
开发者ID:ndech,项目名称:Alpha,代码行数:8,代码来源:TexturedRectangle.cs
示例17: DepthStencilCube
/// <summary>
/// Creates render target
/// </summary>
/// <param name="rs"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="format"></param>
public DepthStencilCube( GraphicsDevice device, DepthFormat format, int size, int samples, string debugName = "" )
: base(device)
{
bool msaa = samples > 1;
CheckSamplesCount( samples );
SampleCount = samples;
Format = format;
SampleCount = samples;
Width = size;
Height = size;
Depth = 1;
var texDesc = new Texture2DDescription();
texDesc.Width = Width;
texDesc.Height = Height;
texDesc.ArraySize = 6;
texDesc.BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource;
texDesc.CpuAccessFlags = CpuAccessFlags.None;
texDesc.Format = Converter.ConvertToTex( format );
texDesc.MipLevels = 1;
texDesc.OptionFlags = ResourceOptionFlags.TextureCube;
texDesc.SampleDescription = new DXGI.SampleDescription(samples, 0);
texDesc.Usage = ResourceUsage.Default;
texCube = new D3D.Texture2D( device.Device, texDesc );
var srvDesc = new ShaderResourceViewDescription();
srvDesc.Dimension = samples > 1 ? ShaderResourceViewDimension.Texture2DMultisampled : ShaderResourceViewDimension.Texture2D;
srvDesc.Format = Converter.ConvertToSRV( format );
srvDesc.Texture2D.MostDetailedMip = 0;
srvDesc.Texture2D.MipLevels = 1;
SRV = new ShaderResourceView( device.Device, texCube );
//
// Create surfaces :
//
surfaces = new DepthStencilSurface[ 6 ];
for ( int face=0; face<6; face++) {
var rtvDesc = new DepthStencilViewDescription();
rtvDesc.Texture2DArray.MipSlice = 0;
rtvDesc.Texture2DArray.FirstArraySlice = face;
rtvDesc.Texture2DArray.ArraySize = 1;
rtvDesc.Dimension = msaa ? DepthStencilViewDimension.Texture2DMultisampledArray : DepthStencilViewDimension.Texture2DArray;
rtvDesc.Format = Converter.ConvertToDSV( format );
var dsv = new DepthStencilView( device.Device, texCube, rtvDesc );
int subResId = Resource.CalculateSubResourceIndex( 0, face, 1 );
surfaces[face] = new DepthStencilSurface( dsv, format, Width, Height, SampleCount );
}
}
开发者ID:temik911,项目名称:audio,代码行数:65,代码来源:DepthStencilCube.cs
示例18: DynamicDepthTexture
/// <summary>
/// Creates a dynamic depth texture, allocates GPU resources
/// </summary>
/// <param name="device">Direct3D Device</param>
public DynamicDepthTexture(Device device)
{
if (device == null)
throw new ArgumentNullException("device");
this.texture = new Texture2D(device, DepthTextureDescriptors.DynamicResource);
this.rawView = new ShaderResourceView(device,this.texture, DepthTextureDescriptors.RawView);
this.normalizedView = new ShaderResourceView(device,this.texture, DepthTextureDescriptors.NormalizedView);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:13,代码来源:DynamicDepthTexture.cs
示例19: DynamicHdFaceStructuredBuffer
/// <summary>
/// Constructor
/// </summary>
/// <param name="device">Direct3D11 Device</param>
/// <param name="maxFaceCount">Maximum body count</param>
public DynamicHdFaceStructuredBuffer(Device device, int maxFaceCount)
{
if (device == null)
throw new ArgumentNullException("device");
var desc = DescriptorUtils.DynamicStructuredBuffer(new BufferElementCount(maxFaceCount * (int)Microsoft.Kinect.Face.FaceModel.VertexCount), new BufferStride(12));
this.buffer = new SharpDX.Direct3D11.Buffer(device, desc);
this.shaderView = new ShaderResourceView(device, this.buffer);
}
开发者ID:semihguresci,项目名称:kgp,代码行数:14,代码来源:DynamicHdFaceStructuredBuffer.cs
示例20: Apply
public virtual void Apply(DeviceContext context, ShaderResourceView source, RenderTargetView destination, float scale = 1f, float offset = 0f)
{
context.OutputMerger.SetTargets(destination);
context.PixelShader.SetShaderResource(0, source);
Texture2D tex2D = destination.ResourceAs<Texture2D>();
context.Rasterizer.SetViewport(0f, 0f, (float)tex2D.Description.Width, (float)tex2D.Description.Height, 0f, 1f);
tex2D.Dispose();
ScreenQuad.Draw(context, scale, offset);
}
开发者ID:romanchom,项目名称:Luna,代码行数:9,代码来源:Filter.cs
注:本文中的SharpDX.Direct3D11.ShaderResourceView类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论