本文整理汇总了C#中ShaderResourceView类的典型用法代码示例。如果您正苦于以下问题:C# ShaderResourceView类的具体用法?C# ShaderResourceView怎么用?C# ShaderResourceView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShaderResourceView类属于命名空间,在下文中一共展示了ShaderResourceView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize(Device device, int resolutionX, int resolutionY)
{
m_BokehSpriteTexture = Texture2D.FromFile(device, "textures\\bokeh.dds");
m_BokehSpriteTextureSRV = new ShaderResourceView(device, m_BokehSpriteTexture);
m_HalfResDescriptor = new RenderTargetSet.RenderTargetDescriptor()
{
m_Format = Format.R16G16B16A16_Float,
m_HasDepth = false,
m_NumSurfaces = 1,
m_Height = resolutionY / 2,
m_Width = resolutionX / 2
};
m_HalfHeightDescriptor = new RenderTargetSet.RenderTargetDescriptor()
{
m_Format = Format.R16G16B16A16_Float,
m_HasDepth = false,
m_NumSurfaces = 1,
m_Height = resolutionY / 2,
m_Width = resolutionX
};
m_NumQuads = resolutionX * resolutionY / 4;
}
示例2: DX11DynamicStructuredBuffer
public DX11DynamicStructuredBuffer(Device dev, Buffer buffer, int cnt) //Dynamic default buffer
{
this.Size = cnt;
this.Buffer = buffer;
this.Stride = buffer.Description.StructureByteStride;
this.SRV = new ShaderResourceView(dev, this.Buffer);
}
示例3: Update
public void Update(IPluginIO pin, DX11RenderContext context)
{
if (this.FInvalidate)
{
if (srv != null) { srv.Dispose(); }
if (tex != null) { tex.Dispose(); }
try
{
int p = unchecked((int) this.FPointer[0]);
tex = context.Device.OpenSharedResource<Texture2D>(new IntPtr(p));
srv = new ShaderResourceView(context.Device, tex);
DX11Texture2D resource = DX11Texture2D.FromTextureAndSRV(context, tex, srv);
this.FTextureOutput[0][context] = resource;
this.FValid[0] = true;
}
catch (Exception ex)
{
this.FValid[0] = false;
}
this.FInvalidate = false;
}
}
示例4: Resize
/// <summary>
/// Resizes the buffer to the nearest power of two >= nElements
/// and sets Count to nElements
/// </summary>
/// <param name="nElements"></param>
public void Resize( int nElements )
{
if( nElements > Capacity || // if we need more than we currently have allocated
nElements < Capacity / 2 ) // or if the current one is more than twice as big
{
Capacity = nElements.RoundUpToNearestPowerOfTwo();
if( Buffer != null )
{
View.Dispose();
Buffer.Dispose();
}
Buffer = BufferFactory.CreateDynamicDataBuffer( Capacity, ElementSizeBytes );
var srv = new ShaderResourceViewDescription()
{
ArraySize = 1,
Format = SlimDX.DXGI.Format.R32G32B32A32_Float,
Dimension = ShaderResourceViewDimension.Buffer,
ElementOffset = 0,
ElementWidth = ElementSizeBytes
};
View = new ShaderResourceView( D3D10Wrapper.Instance.Device, Buffer, srv );
}
Count = nElements;
}
示例5: SimpleObject
public SimpleObject(string name, IServiceProvider services, PositionTexCoordNormalVertex[] vertices, short[] indices,
string effectAsset, string diffuseMapAsset)
: base(name)
{
if (services == null)
throw new ArgumentNullException("services");
if (vertices == null)
throw new ArgumentNullException("vertices");
if (indices == null)
throw new ArgumentNullException("indices");
batchesRO = new BatchReadOnlyCollection(batches);
// Services
var resourceManager = (ResourceManager)services.GetService(typeof(ResourceManager));
var renderer = (Renderer)services.GetService(typeof(Renderer));
// Load effect & textures
effect = resourceManager.Load<Effect>(effectAsset, false);
diffuseMapView = new ShaderResourceView(renderer.Device, resourceManager.Load<Texture2D>(diffuseMapAsset));
effect.SetVariableByName("DiffuseMap", diffuseMapView, true);
// Create batch
CreateBatch(vertices, indices, renderer);
// Calculate boundary
CalculateBoundary(vertices);
}
示例6: Draw
public void Draw(DeviceContextHolder holder, ShaderResourceView view, RenderTargetView target,
TargetResourceTexture temporaryEdges, TargetResourceTexture temporaryBlending) {
holder.PrepareQuad(_effect.LayoutPT);
holder.DeviceContext.OutputMerger.BlendState = null;
// edges
holder.DeviceContext.OutputMerger.SetTargets(temporaryEdges.TargetView);
holder.DeviceContext.ClearRenderTargetView(temporaryEdges.TargetView, new Color4(0f, 0f, 0f, 0f));
_effect.FxScreenSizeSpec.Set(new Vector4(1f / holder.Width, 1f / holder.Height, holder.Width, holder.Height));
_effect.FxInputMap.SetResource(view);
_effect.TechSmaa.DrawAllPasses(holder.DeviceContext, 6);
// blending
holder.DeviceContext.OutputMerger.SetTargets(temporaryBlending.TargetView);
holder.DeviceContext.ClearRenderTargetView(temporaryBlending.TargetView, new Color4(0f, 0f, 0f, 0f));
_effect.FxEdgesMap.SetResource(temporaryEdges.View);
_effect.FxAreaTexMap.SetResource(_areasTexMap);
_effect.FxSearchTexMap.SetResource(_searchTexMap);
_effect.TechSmaaB.DrawAllPasses(holder.DeviceContext, 6);
// final part
holder.DeviceContext.OutputMerger.SetTargets(target);
_effect.FxBlendMap.SetResource(temporaryBlending.View);
_effect.TechSmaaN.DrawAllPasses(holder.DeviceContext, 6);
}
示例7: RenderTexture
/// <summary>
/// Constructor
/// Creates the texture we will render to based on the supplied width and height
/// </summary>
/// <param name="device">The device we will create the texture with</param>
/// <param name="texWidth"></param>
/// <param name="texHeight"></param>
public RenderTexture(Device device, int texWidth, int texHeight)
{
Texture2DDescription textureDescription = new Texture2DDescription()
{
Width = texWidth,
Height = texHeight,
MipLevels = 1,
ArraySize = 1,
Format = SlimDX.DXGI.Format.R32G32B32A32_Float,
SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None,
Usage = ResourceUsage.Default,
};
Texture = new Texture2D(device, textureDescription);
RenderTargetViewDescription renderTargetViewDescription = new RenderTargetViewDescription()
{
Format = textureDescription.Format,
Dimension = RenderTargetViewDimension.Texture2D,
MipSlice = 0,
};
renderTargetView = new RenderTargetView(device, Texture, renderTargetViewDescription);
ShaderResourceViewDescription shaderResourceViewDescription = new ShaderResourceViewDescription()
{
Format = textureDescription.Format,
Dimension = ShaderResourceViewDimension.Texture2D,
MostDetailedMip = 0,
MipLevels = 1
};
shaderResourceView = new ShaderResourceView(device, Texture, shaderResourceViewDescription);
}
示例8: CircleEffect
public CircleEffect(GameContext context)
: base(context)
{
_context = context;
effect = CGHelper.CreateEffectFx5("Resources\\Shader\\circleShader.fx",
context.RenderContext.DeviceManager.Device);
beffect = CGHelper.CreateEffectFx5("Resources\\Shader\\convergenceBeam.fx",
context.RenderContext.DeviceManager.Device);
noiseView = context.LoadTexture("Resources\\Effect\\noise.png");
beamView = context.LoadTexture("Resources\\Effect\\lazer.png");
ShaderResourceView view = context.LoadTexture("Resources\\Effect\\circle.png");
frontCircle = new DividedPlaneBoard(context.RenderContext, view,100,
new Vector2(100, 100),
new PlaneBoard.PlaneBoardDescription(BlendStateManager.BlendStates.Add, effect, false, RenderFront));
frontCircle.Initialize();
for (int i = 0; i < 3; i++)
{
subCircle[i] = new PlaneBoard(context.RenderContext, view, new Vector2(30, 30),
new PlaneBoard.PlaneBoardDescription(BlendStateManager.BlendStates.Add, effect, false, RenderFront));
subCircle[i].Initialize();
}
for (int i = 0; i < 5; i++)
{
beamEffects[i]=new DividedPlaneBoard(context.RenderContext, view, 100,
new Vector2(100, 100),
new PlaneBoard.PlaneBoardDescription(BlendStateManager.BlendStates.Add, beffect, false, Renderbeam));
beamEffects[i].Initialize();
}
}
示例9: Update
public void Update(IPluginIO pin, DX11RenderContext context)
{
if (this.FInvalidate)
{
if (this.FTextureOutput[0].Contains(context))
{
this.FTextureOutput[0].Dispose(context);
}
try
{
Texture2D tex = context.Device.OpenSharedResource<Texture2D>((IntPtr)this.FPointer[0]);
ShaderResourceView srv = new ShaderResourceView(context.Device, tex);
DX11Texture2D resource = DX11Texture2D.FromTextureAndSRV(context, tex, srv);
this.FTextureOutput[0][context] = resource;
this.FValid[0] = true;
}
catch (Exception ex)
{
this.FValid[0] = false;
}
this.FInvalidate = false;
}
}
示例10: LoadResources
public void LoadResources()
{
if (m_Disposed == true)
{
Buffer = new Texture2D(GameEnvironment.Device, new Texture2DDescription()
{
Format = m_Format,
Width = m_Width,
Height = m_Height,
OptionFlags = ResourceOptionFlags.None,
MipLevels = 1,
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default
});
View = new RenderTargetView(GameEnvironment.Device, Buffer);
ResourceView = new ShaderResourceView(GameEnvironment.Device, Buffer);
Viewport = new Viewport(0, 0, Buffer.Description.Width, Buffer.Description.Height);
m_Disposed = false;
}
}
示例11: Resize
public override void Resize(DeviceContextHolder holder, int width, int height) {
if (width == Width && height == Height) return;
base.Resize(holder, width, height);
TargetView = new RenderTargetView(holder.Device, Texture);
View = new ShaderResourceView(holder.Device, Texture);
}
示例12: FieldPlane
/// <summary>
/// Plane to display scalar/vector field data on. Condition: Fields domain is 2D.
/// </summary>
/// <param name="origin"></param>
/// <param name="xAxis"></param>
/// <param name="yAxis"></param>
/// <param name="scale">Scaling the field extent.</param>
/// <param name="field"></param>
public FieldPlane(Plane plane, VectorField fields, RenderEffect effect = RenderEffect.DEFAULT, Colormap map = Colormap.Parula)
{
#if DEBUG
// Assert that the fields are 2 dimensional.
foreach(Field field in fields.Scalars)
System.Diagnostics.Debug.Assert(field.Size.Length >= 2);
#endif
this._effect = _planeEffect;
this._vertexSizeBytes = 32;
this._numVertices = 6;
this.UsedMap = map;
this._width = fields[0].Size[0];
this._height = fields[0].Size[1];
this._invalid = fields.InvalidValue ?? float.MaxValue;
this._field = fields;
// Setting up the vertex buffer.
GenerateGeometry(plane, fields[0].Size.ToInt2(), fields.TimeSlice??0);
// Generating Textures from the fields.
_fieldTextures = new ShaderResourceView[fields.Scalars.Length];
for(int f = 0; f < _field.NumVectorDimensions; ++f)
{
Texture2D tex = ColorMapping.GenerateTextureFromField(_device, fields[f]);
_fieldTextures[f] = new ShaderResourceView(_device, tex);
}
this.SetRenderEffect(effect);
this._vertexLayout = new InputLayout(_device, _technique.GetPassByIndex(0).Description.Signature, new[] {
new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
new InputElement("TEXTURE", 0, Format.R32G32B32A32_Float, 16, 0)
});
}
示例13: Update
public void Update(IPluginIO pin, DX11RenderContext context)
{
if (this.FInvalidate)
{
for (int i = 0; i < FTextureOutput.SliceCount; i++)
{
if (this.FTextureOutput[i].Contains(context))
{
this.FTextureOutput[i].Dispose(context);
}
try
{
int p = unchecked((int) this.FPointer[i]);
IntPtr share = new IntPtr(p);
Texture2D tex = context.Device.OpenSharedResource<Texture2D>(share);
ShaderResourceView srv = new ShaderResourceView(context.Device, tex);
DX11Texture2D resource = DX11Texture2D.FromTextureAndSRV(context, tex, srv);
this.FTextureOutput[i][context] = resource;
this.FValid[i] = true;
}
catch (Exception)
{
this.FValid[i] = false;
}
}
this.FInvalidate = false;
}
}
示例14: SetProceduralOverride
public void SetProceduralOverride(byte[] textureBytes, Device device) {
try {
ProceduralOverride = ShaderResourceView.FromMemory(device, textureBytes);
} catch (Exception) {
ProceduralOverride = null;
}
}
示例15: LoadResources
public void LoadResources()
{
if (m_Disposed == true)
{
if (m_Filename != null)
{
m_ImposterTexture = Texture2D.FromFile(GameEnvironment.Device, Helper.ResolvePath(m_Filename));
TextureView = new ShaderResourceView(GameEnvironment.Device, m_ImposterTexture);
}
m_Vertices = new SlimDX.Direct3D11.Buffer(GameEnvironment.Device, new BufferDescription()
{
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
SizeInBytes = 4 * Marshal.SizeOf(typeof(Vertex2D)),
Usage = ResourceUsage.Dynamic
});
m_VerticesBindings = new VertexBufferBinding(m_Vertices, Marshal.SizeOf(typeof(Vertex2D)), 0);
WriteRectangle();
m_Disposed = false;
}
}