Trait gfx::Factory
[−]
[src]
pub trait Factory<R> where
R: Resources, { fn get_capabilities(&self) -> &Capabilities; fn create_buffer_raw(&mut self, Info) -> Result<RawBuffer<R>, CreationError>; fn create_buffer_immutable_raw(
&mut self,
data: &[u8],
stride: usize,
Role,
Bind
) -> Result<RawBuffer<R>, CreationError>; fn create_pipeline_state_raw(
&mut self,
&Program<R>,
&Descriptor
) -> Result<RawPipelineState<R>, CreationError>; fn create_program(
&mut self,
shader_set: &ShaderSet<R>
) -> Result<Program<R>, CreateProgramError>; fn create_shader(
&mut self,
stage: Stage,
code: &[u8]
) -> Result<Shader<R>, CreateShaderError>; fn create_sampler(&mut self, SamplerInfo) -> Sampler<R>; fn read_mapping<T>(
&'a mut self,
buf: &'b Buffer<R, T>
) -> Result<Reader<'b, R, T>, Error>
where
T: Copy; fn write_mapping<T>(
&'a mut self,
buf: &'b Buffer<R, T>
) -> Result<Writer<'b, R, T>, Error>
where
T: Copy; fn create_texture_raw(
&mut self,
Info,
Option<ChannelType>,
Option<&[&[u8]]>
) -> Result<RawTexture<R>, CreationError>; fn view_buffer_as_shader_resource_raw(
&mut self,
&RawBuffer<R>
) -> Result<RawShaderResourceView<R>, ResourceViewError>; fn view_buffer_as_unordered_access_raw(
&mut self,
&RawBuffer<R>
) -> Result<RawUnorderedAccessView<R>, ResourceViewError>; fn view_texture_as_shader_resource_raw(
&mut self,
&RawTexture<R>,
ResourceDesc
) -> Result<RawShaderResourceView<R>, ResourceViewError>; fn view_texture_as_unordered_access_raw(
&mut self,
&RawTexture<R>
) -> Result<RawUnorderedAccessView<R>, ResourceViewError>; fn view_texture_as_render_target_raw(
&mut self,
&RawTexture<R>,
RenderDesc
) -> Result<RawRenderTargetView<R>, TargetViewError>; fn view_texture_as_depth_stencil_raw(
&mut self,
&RawTexture<R>,
DepthStencilDesc
) -> Result<RawDepthStencilView<R>, TargetViewError>; fn create_buffer_immutable<T>(
&mut self,
data: &[T],
role: Role,
bind: Bind
) -> Result<Buffer<R, T>, CreationError>
where
T: Pod, { ... } fn create_buffer<T>(
&mut self,
num: usize,
role: Role,
usage: Usage,
bind: Bind
) -> Result<Buffer<R, T>, CreationError> { ... } fn create_shader_vertex(
&mut self,
code: &[u8]
) -> Result<VertexShader<R>, CreateShaderError> { ... } fn create_shader_hull(
&mut self,
code: &[u8]
) -> Result<HullShader<R>, CreateShaderError> { ... } fn create_shader_domain(
&mut self,
code: &[u8]
) -> Result<DomainShader<R>, CreateShaderError> { ... } fn create_shader_geometry(
&mut self,
code: &[u8]
) -> Result<GeometryShader<R>, CreateShaderError> { ... } fn create_shader_pixel(
&mut self,
code: &[u8]
) -> Result<PixelShader<R>, CreateShaderError> { ... } fn create_texture<S>(
&mut self,
kind: Kind,
levels: u8,
bind: Bind,
usage: Usage,
channel_hint: Option<ChannelType>
) -> Result<Texture<R, S>, CreationError>
where
S: SurfaceTyped, { ... } fn view_buffer_as_shader_resource<T>(
&mut self,
buf: &Buffer<R, T>
) -> Result<ShaderResourceView<R, T>, ResourceViewError> { ... } fn view_buffer_as_unordered_access<T>(
&mut self,
buf: &Buffer<R, T>
) -> Result<UnorderedAccessView<R, T>, ResourceViewError> { ... } fn view_texture_as_shader_resource<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
levels: (u8, u8),
swizzle: Swizzle
) -> Result<ShaderResourceView<R, <T as Formatted>::View>, ResourceViewError>
where
T: TextureFormat, { ... } fn view_texture_as_unordered_access<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>
) -> Result<UnorderedAccessView<R, <T as Formatted>::View>, ResourceViewError>
where
T: TextureFormat, { ... } fn view_texture_as_render_target<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
level: u8,
layer: Option<u16>
) -> Result<RenderTargetView<R, T>, TargetViewError>
where
T: RenderFormat, { ... } fn view_texture_as_depth_stencil<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
level: u8,
layer: Option<u16>,
flags: DepthStencilFlags
) -> Result<DepthStencilView<R, T>, TargetViewError>
where
T: DepthFormat, { ... } fn view_texture_as_depth_stencil_trivial<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>
) -> Result<DepthStencilView<R, T>, TargetViewError>
where
T: DepthFormat, { ... } fn create_texture_immutable_u8<T>(
&mut self,
kind: Kind,
data: &[&[u8]]
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>), CombinedError>
where
T: TextureFormat, { ... } fn create_texture_immutable<T>(
&mut self,
kind: Kind,
data: &[&[<<T as Formatted>::Surface as SurfaceTyped>::DataType]]
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>), CombinedError>
where
T: TextureFormat, { ... } fn create_render_target<T>(
&mut self,
width: u16,
height: u16
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>, RenderTargetView<R, T>), CombinedError>
where
T: TextureFormat + RenderFormat, { ... } fn create_depth_stencil<T>(
&mut self,
width: u16,
height: u16
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>, DepthStencilView<R, T>), CombinedError>
where
T: DepthFormat + TextureFormat, { ... } fn create_depth_stencil_view_only<T>(
&mut self,
width: u16,
height: u16
) -> Result<DepthStencilView<R, T>, CombinedError>
where
T: DepthFormat + TextureFormat, { ... } }
A Factory is responsible for creating and managing resources for the context it was created
with.
Construction and Handling
A Factory is typically created along with other objects using a helper function of the
appropriate gfx_window module (e.g. gfx_window_glutin::init()).
This factory structure can then be used to create and manage different resources, like buffers, shader programs and textures. See the individual methods for more information.
Also see the FactoryExt trait inside the gfx module for additional methods.
Required Methods
fn get_capabilities(&self) -> &Capabilities
Returns the capabilities of this Factory. This usually depends on the graphics API being
used.
fn create_buffer_raw(&mut self, Info) -> Result<RawBuffer<R>, CreationError>
fn create_buffer_immutable_raw(
&mut self,
data: &[u8],
stride: usize,
Role,
Bind
) -> Result<RawBuffer<R>, CreationError>
&mut self,
data: &[u8],
stride: usize,
Role,
Bind
) -> Result<RawBuffer<R>, CreationError>
fn create_pipeline_state_raw(
&mut self,
&Program<R>,
&Descriptor
) -> Result<RawPipelineState<R>, CreationError>
&mut self,
&Program<R>,
&Descriptor
) -> Result<RawPipelineState<R>, CreationError>
Creates a new RawPipelineState. To create a safely typed PipelineState, see the
FactoryExt trait and pso module, both in the gfx crate.
fn create_program(
&mut self,
shader_set: &ShaderSet<R>
) -> Result<Program<R>, CreateProgramError>
&mut self,
shader_set: &ShaderSet<R>
) -> Result<Program<R>, CreateProgramError>
Creates a new shader Program for the supplied ShaderSet.
fn create_shader(
&mut self,
stage: Stage,
code: &[u8]
) -> Result<Shader<R>, CreateShaderError>
&mut self,
stage: Stage,
code: &[u8]
) -> Result<Shader<R>, CreateShaderError>
Compiles a shader source into a Shader object that can be used to create a shader
Program.
fn create_sampler(&mut self, SamplerInfo) -> Sampler<R>
fn read_mapping<T>(
&'a mut self,
buf: &'b Buffer<R, T>
) -> Result<Reader<'b, R, T>, Error> where
T: Copy,
&'a mut self,
buf: &'b Buffer<R, T>
) -> Result<Reader<'b, R, T>, Error> where
T: Copy,
Acquire a mapping Reader
See write_mapping for more information.
fn write_mapping<T>(
&'a mut self,
buf: &'b Buffer<R, T>
) -> Result<Writer<'b, R, T>, Error> where
T: Copy,
&'a mut self,
buf: &'b Buffer<R, T>
) -> Result<Writer<'b, R, T>, Error> where
T: Copy,
Acquire a mapping Writer
While holding this writer, you hold CPU-side exclusive access. Any access overlap will result in an error. Submitting commands involving this buffer to the device implicitly requires exclusive access. Additionally, further access will be stalled until execution completion.
fn create_texture_raw(
&mut self,
Info,
Option<ChannelType>,
Option<&[&[u8]]>
) -> Result<RawTexture<R>, CreationError>
&mut self,
Info,
Option<ChannelType>,
Option<&[&[u8]]>
) -> Result<RawTexture<R>, CreationError>
Create a new empty raw texture with no data. The channel type parameter is a hint, required to assist backends that have no concept of typeless formats (OpenGL). The initial data, if given, has to be provided for all mip levels and slices: Slice0.Mip0, Slice0.Mip1, ..., Slice1.Mip0, ...
fn view_buffer_as_shader_resource_raw(
&mut self,
&RawBuffer<R>
) -> Result<RawShaderResourceView<R>, ResourceViewError>
&mut self,
&RawBuffer<R>
) -> Result<RawShaderResourceView<R>, ResourceViewError>
fn view_buffer_as_unordered_access_raw(
&mut self,
&RawBuffer<R>
) -> Result<RawUnorderedAccessView<R>, ResourceViewError>
&mut self,
&RawBuffer<R>
) -> Result<RawUnorderedAccessView<R>, ResourceViewError>
fn view_texture_as_shader_resource_raw(
&mut self,
&RawTexture<R>,
ResourceDesc
) -> Result<RawShaderResourceView<R>, ResourceViewError>
&mut self,
&RawTexture<R>,
ResourceDesc
) -> Result<RawShaderResourceView<R>, ResourceViewError>
fn view_texture_as_unordered_access_raw(
&mut self,
&RawTexture<R>
) -> Result<RawUnorderedAccessView<R>, ResourceViewError>
&mut self,
&RawTexture<R>
) -> Result<RawUnorderedAccessView<R>, ResourceViewError>
fn view_texture_as_render_target_raw(
&mut self,
&RawTexture<R>,
RenderDesc
) -> Result<RawRenderTargetView<R>, TargetViewError>
&mut self,
&RawTexture<R>,
RenderDesc
) -> Result<RawRenderTargetView<R>, TargetViewError>
fn view_texture_as_depth_stencil_raw(
&mut self,
&RawTexture<R>,
DepthStencilDesc
) -> Result<RawDepthStencilView<R>, TargetViewError>
&mut self,
&RawTexture<R>,
DepthStencilDesc
) -> Result<RawDepthStencilView<R>, TargetViewError>
Provided Methods
fn create_buffer_immutable<T>(
&mut self,
data: &[T],
role: Role,
bind: Bind
) -> Result<Buffer<R, T>, CreationError> where
T: Pod,
&mut self,
data: &[T],
role: Role,
bind: Bind
) -> Result<Buffer<R, T>, CreationError> where
T: Pod,
fn create_buffer<T>(
&mut self,
num: usize,
role: Role,
usage: Usage,
bind: Bind
) -> Result<Buffer<R, T>, CreationError>
&mut self,
num: usize,
role: Role,
usage: Usage,
bind: Bind
) -> Result<Buffer<R, T>, CreationError>
fn create_shader_vertex(
&mut self,
code: &[u8]
) -> Result<VertexShader<R>, CreateShaderError>
&mut self,
code: &[u8]
) -> Result<VertexShader<R>, CreateShaderError>
Compiles a VertexShader from source.
fn create_shader_hull(
&mut self,
code: &[u8]
) -> Result<HullShader<R>, CreateShaderError>
&mut self,
code: &[u8]
) -> Result<HullShader<R>, CreateShaderError>
Compiles a HullShader from source.
fn create_shader_domain(
&mut self,
code: &[u8]
) -> Result<DomainShader<R>, CreateShaderError>
&mut self,
code: &[u8]
) -> Result<DomainShader<R>, CreateShaderError>
Compiles a VertexShader from source.
fn create_shader_geometry(
&mut self,
code: &[u8]
) -> Result<GeometryShader<R>, CreateShaderError>
&mut self,
code: &[u8]
) -> Result<GeometryShader<R>, CreateShaderError>
Compiles a GeometryShader from source.
fn create_shader_pixel(
&mut self,
code: &[u8]
) -> Result<PixelShader<R>, CreateShaderError>
&mut self,
code: &[u8]
) -> Result<PixelShader<R>, CreateShaderError>
Compiles a PixelShader from source. This is the same as what some APIs call a fragment
shader.
fn create_texture<S>(
&mut self,
kind: Kind,
levels: u8,
bind: Bind,
usage: Usage,
channel_hint: Option<ChannelType>
) -> Result<Texture<R, S>, CreationError> where
S: SurfaceTyped,
&mut self,
kind: Kind,
levels: u8,
bind: Bind,
usage: Usage,
channel_hint: Option<ChannelType>
) -> Result<Texture<R, S>, CreationError> where
S: SurfaceTyped,
fn view_buffer_as_shader_resource<T>(
&mut self,
buf: &Buffer<R, T>
) -> Result<ShaderResourceView<R, T>, ResourceViewError>
&mut self,
buf: &Buffer<R, T>
) -> Result<ShaderResourceView<R, T>, ResourceViewError>
fn view_buffer_as_unordered_access<T>(
&mut self,
buf: &Buffer<R, T>
) -> Result<UnorderedAccessView<R, T>, ResourceViewError>
&mut self,
buf: &Buffer<R, T>
) -> Result<UnorderedAccessView<R, T>, ResourceViewError>
fn view_texture_as_shader_resource<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
levels: (u8, u8),
swizzle: Swizzle
) -> Result<ShaderResourceView<R, <T as Formatted>::View>, ResourceViewError> where
T: TextureFormat,
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
levels: (u8, u8),
swizzle: Swizzle
) -> Result<ShaderResourceView<R, <T as Formatted>::View>, ResourceViewError> where
T: TextureFormat,
fn view_texture_as_unordered_access<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>
) -> Result<UnorderedAccessView<R, <T as Formatted>::View>, ResourceViewError> where
T: TextureFormat,
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>
) -> Result<UnorderedAccessView<R, <T as Formatted>::View>, ResourceViewError> where
T: TextureFormat,
fn view_texture_as_render_target<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
level: u8,
layer: Option<u16>
) -> Result<RenderTargetView<R, T>, TargetViewError> where
T: RenderFormat,
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
level: u8,
layer: Option<u16>
) -> Result<RenderTargetView<R, T>, TargetViewError> where
T: RenderFormat,
fn view_texture_as_depth_stencil<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
level: u8,
layer: Option<u16>,
flags: DepthStencilFlags
) -> Result<DepthStencilView<R, T>, TargetViewError> where
T: DepthFormat,
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>,
level: u8,
layer: Option<u16>,
flags: DepthStencilFlags
) -> Result<DepthStencilView<R, T>, TargetViewError> where
T: DepthFormat,
fn view_texture_as_depth_stencil_trivial<T>(
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>
) -> Result<DepthStencilView<R, T>, TargetViewError> where
T: DepthFormat,
&mut self,
tex: &Texture<R, <T as Formatted>::Surface>
) -> Result<DepthStencilView<R, T>, TargetViewError> where
T: DepthFormat,
fn create_texture_immutable_u8<T>(
&mut self,
kind: Kind,
data: &[&[u8]]
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>), CombinedError> where
T: TextureFormat,
&mut self,
kind: Kind,
data: &[&[u8]]
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>), CombinedError> where
T: TextureFormat,
fn create_texture_immutable<T>(
&mut self,
kind: Kind,
data: &[&[<<T as Formatted>::Surface as SurfaceTyped>::DataType]]
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>), CombinedError> where
T: TextureFormat,
&mut self,
kind: Kind,
data: &[&[<<T as Formatted>::Surface as SurfaceTyped>::DataType]]
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>), CombinedError> where
T: TextureFormat,
fn create_render_target<T>(
&mut self,
width: u16,
height: u16
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>, RenderTargetView<R, T>), CombinedError> where
T: TextureFormat + RenderFormat,
&mut self,
width: u16,
height: u16
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>, RenderTargetView<R, T>), CombinedError> where
T: TextureFormat + RenderFormat,
fn create_depth_stencil<T>(
&mut self,
width: u16,
height: u16
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>, DepthStencilView<R, T>), CombinedError> where
T: DepthFormat + TextureFormat,
&mut self,
width: u16,
height: u16
) -> Result<(Texture<R, <T as Formatted>::Surface>, ShaderResourceView<R, <T as Formatted>::View>, DepthStencilView<R, T>), CombinedError> where
T: DepthFormat + TextureFormat,
fn create_depth_stencil_view_only<T>(
&mut self,
width: u16,
height: u16
) -> Result<DepthStencilView<R, T>, CombinedError> where
T: DepthFormat + TextureFormat,
&mut self,
width: u16,
height: u16
) -> Result<DepthStencilView<R, T>, CombinedError> where
T: DepthFormat + TextureFormat,