pub struct GraphicsContext {
pub instance: Instance,
pub adapter: Adapter,
pub device: Device,
pub queue: Queue,
/* private fields */
}Expand description
A globally shared graphics context.
§Ownership Pattern
This type uses Arc for shared ownership:
use astrelis_render::GraphicsContext;
use std::sync::Arc;
// Synchronous creation (blocks on async internally)
let ctx = GraphicsContext::new_owned_sync_or_panic(); // Returns Arc<Self>
let ctx2 = ctx.clone(); // Cheap clone (Arc)
// Asynchronous creation (for async contexts)
let ctx = GraphicsContext::new_owned().await; // Returns Arc<Self>Benefits of the Arc pattern:
- No memory leak
- Proper cleanup on drop
- Better for testing (can create/destroy contexts)
- Arc internally makes cloning cheap
Fields§
§instance: Instance§adapter: Adapter§device: Device§queue: QueueImplementations§
Source§impl GraphicsContext
impl GraphicsContext
Sourcepub async fn new_owned() -> Result<Arc<Self>, GraphicsError>
pub async fn new_owned() -> Result<Arc<Self>, GraphicsError>
Creates a new graphics context with owned ownership (recommended).
Returns Arc<Self> which can be cheaply cloned and shared.
This is the preferred method for new code as it doesn’t leak memory.
§Example
use astrelis_render::GraphicsContext;
let ctx = GraphicsContext::new_owned().await;
let ctx2 = ctx.clone(); // Cheap cloneSourcepub fn new_owned_sync() -> Result<Arc<Self>, GraphicsError>
pub fn new_owned_sync() -> Result<Arc<Self>, GraphicsError>
Creates a new graphics context synchronously with owned ownership (recommended).
This blocks the current thread until the context is created.
§Errors
Returns GraphicsError if:
- No suitable GPU adapter is found
- Required GPU features are not supported
- Device creation fails
Sourcepub fn new_owned_sync_or_panic() -> Arc<Self>
pub fn new_owned_sync_or_panic() -> Arc<Self>
Creates a new graphics context synchronously, panicking on error.
This is a convenience method for tests and examples where error handling
is not needed. For production code, prefer new_owned_sync() which returns
a Result.
§Panics
Panics if graphics context creation fails.
Examples found in repository?
33fn main() {
34 logging::init();
35
36 run_app(|ctx| {
37 let graphics_ctx = GraphicsContext::new_owned_sync_or_panic();
38 let mut window_manager = WindowManager::new(graphics_ctx);
39 let mut window_colors = HashMap::new();
40
41 // Create 3 windows with different colors
42 let colors = [
43 Color::rgb(0.8, 0.2, 0.2), // Red
44 Color::rgb(0.2, 0.8, 0.2), // Green
45 Color::rgb(0.2, 0.2, 0.8), // Blue
46 ];
47
48 for (i, color) in colors.iter().enumerate() {
49 let window_id = window_manager.create_window_with_descriptor(
50 ctx,
51 WindowDescriptor {
52 title: format!("Window {} - WindowManager Demo", i + 1),
53 size: Some(WinitPhysicalSize::new(400.0, 300.0)),
54 ..Default::default()
55 },
56 WindowContextDescriptor {
57 format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
58 ..Default::default()
59 },
60 ).expect("Failed to create window");
61
62 window_colors.insert(window_id, *color);
63 }
64
65 Box::new(WindowManagerApp {
66 window_manager,
67 window_colors,
68 })
69 });
70}More examples
28fn main() {
29 logging::init();
30
31 run_app(|ctx| {
32 let graphics_ctx = GraphicsContext::new_owned_sync_or_panic();
33
34 let mut windows = HashMap::new();
35
36 // Create 3 windows with different colors
37 let colors = [
38 wgpu::Color {
39 r: 0.8,
40 g: 0.2,
41 b: 0.2,
42 a: 1.0,
43 },
44 wgpu::Color {
45 r: 0.2,
46 g: 0.8,
47 b: 0.2,
48 a: 1.0,
49 },
50 wgpu::Color {
51 r: 0.2,
52 g: 0.2,
53 b: 0.8,
54 a: 1.0,
55 },
56 ];
57
58 for (i, color) in colors.iter().enumerate() {
59 let window = ctx
60 .create_window(WindowDescriptor {
61 title: format!("Window {} - Multi-Window Example", i + 1),
62 size: Some(WinitPhysicalSize::new(400.0, 300.0)),
63 ..Default::default()
64 })
65 .expect("Failed to create window");
66
67 let renderable_window = RenderableWindow::new_with_descriptor(
68 window,
69 graphics_ctx.clone(),
70 WindowContextDescriptor {
71 format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
72 ..Default::default()
73 },
74 ).expect("Failed to create renderable window");
75
76 let window_id = renderable_window.id();
77 windows.insert(window_id, (renderable_window, *color));
78 }
79
80 Box::new(App {
81 context: graphics_ctx,
82 windows,
83 })
84 });
85}36fn main() {
37 logging::init();
38
39 run_app(|ctx| {
40 let graphics_ctx = GraphicsContext::new_owned_sync_or_panic();
41
42 let window = ctx
43 .create_window(WindowDescriptor {
44 title: "Performance Benchmark - Render Stress Test".to_string(),
45 size: Some(WinitPhysicalSize::new(1280.0, 720.0)),
46 ..Default::default()
47 })
48 .expect("Failed to create window");
49
50 let window = RenderableWindow::new_with_descriptor(
51 window,
52 graphics_ctx.clone(),
53 WindowContextDescriptor {
54 format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
55 ..Default::default()
56 },
57 ).expect("Failed to create renderable window");
58
59 let window_id = window.id();
60
61 println!("\n═══════════════════════════════════════════════════════");
62 println!(" ⚡ PERFORMANCE BENCHMARK - Render Stress Test");
63 println!("═══════════════════════════════════════════════════════");
64 println!(" CONTROLS:");
65 println!(" [Space] Toggle rendering on/off");
66 println!(" [+/-] Increase/decrease object count");
67 println!(" Starting with 1000 objects");
68 println!("═══════════════════════════════════════════════════════\n");
69
70 Box::new(PerformanceBenchmark {
71 _context: graphics_ctx,
72 window,
73 window_id,
74 object_count: 1000,
75 rendering: true,
76 frame_count: 0,
77 last_fps_time: Instant::now(),
78 fps: 0.0,
79 last_frame_time: 0.0,
80 })
81 });
82}29fn main() {
30 logging::init();
31
32 run_app(|ctx| {
33 let graphics_ctx = GraphicsContext::new_owned_sync_or_panic();
34
35 let window = ctx
36 .create_window(WindowDescriptor {
37 title: "Camera Demo - View & Projection".to_string(),
38 size: Some(WinitPhysicalSize::new(1024.0, 768.0)),
39 ..Default::default()
40 })
41 .expect("Failed to create window");
42
43 let window = RenderableWindow::new_with_descriptor(
44 window,
45 graphics_ctx.clone(),
46 WindowContextDescriptor {
47 format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
48 ..Default::default()
49 },
50 ).expect("Failed to create renderable window");
51
52 let window_id = window.id();
53
54 println!("\n═══════════════════════════════════════════════════════");
55 println!(" 📹 CAMERA DEMO - View & Projection");
56 println!("═══════════════════════════════════════════════════════");
57 println!("\n CAMERA API FEATURES:");
58 println!(" • Orthographic cameras (2D, UI, isometric)");
59 println!(" • Perspective cameras (3D scenes)");
60 println!(" • View matrix (position, rotation, look-at)");
61 println!(" • Projection matrix (FOV, aspect, near/far planes)");
62 println!(" • Screen-to-world coordinate conversion");
63 println!(" • Camera movement helpers");
64 println!("\n CAMERA TYPES:");
65 println!(" • OrthographicCamera - 2D games, UI overlays");
66 println!(" camera.orthographic(left, right, bottom, top, near, far)");
67 println!(" • PerspectiveCamera - 3D scenes");
68 println!(" camera.perspective(fov, aspect, near, far)");
69 println!("\n Camera API Usage:");
70 println!(" let camera = Camera::new()");
71 println!(" .position(Vec3::new(0.0, 5.0, 10.0))");
72 println!(" .look_at(Vec3::ZERO)");
73 println!(" .perspective(60.0, aspect, 0.1, 100.0);");
74 println!(" let view_proj = camera.view_projection_matrix();");
75 println!("═══════════════════════════════════════════════════════\n");
76
77 tracing::info!("Camera demo initialized");
78
79 Box::new(CameraDemo {
80 _context: graphics_ctx,
81 window,
82 window_id,
83 })
84 });
85}28fn main() {
29 logging::init();
30
31 run_app(|ctx| {
32 let graphics_ctx = GraphicsContext::new_owned_sync_or_panic();
33
34 let window = ctx
35 .create_window(WindowDescriptor {
36 title: "Render Graph Demo - Multi-Pass Rendering".to_string(),
37 size: Some(WinitPhysicalSize::new(1024.0, 768.0)),
38 ..Default::default()
39 })
40 .expect("Failed to create window");
41
42 let window = RenderableWindow::new_with_descriptor(
43 window,
44 graphics_ctx.clone(),
45 WindowContextDescriptor {
46 format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
47 ..Default::default()
48 },
49 ).expect("Failed to create renderable window");
50
51 let window_id = window.id();
52
53 println!("\n═══════════════════════════════════════════════════════");
54 println!(" 🔀 RENDER GRAPH DEMO - Multi-Pass Rendering");
55 println!("═══════════════════════════════════════════════════════");
56 println!("\n RENDER GRAPH FEATURES:");
57 println!(" • Declarative pass definition");
58 println!(" • Automatic dependency resolution");
59 println!(" • Resource lifetime management");
60 println!(" • Parallel pass execution");
61 println!(" • Automatic optimization");
62 println!("\n EXAMPLE PIPELINE:");
63 println!(" 1. Shadow Pass → depth texture");
64 println!(" 2. Geometry Pass → color + normal + depth");
65 println!(" 3. Lighting Pass → lit scene");
66 println!(" 4. Post-Processing → bloom, tone mapping");
67 println!(" 5. UI Pass → final composite");
68 println!("\n Render Graph API Usage:");
69 println!(" let mut graph = RenderGraph::new();");
70 println!(" graph.add_pass(\"shadow\", shadow_pass_descriptor);");
71 println!(" graph.add_pass(\"geometry\", geometry_pass_descriptor);");
72 println!(" graph.add_dependency(\"lighting\", \"geometry\");");
73 println!(" graph.compile();");
74 println!(" graph.execute(&mut encoder);");
75 println!("═══════════════════════════════════════════════════════\n");
76
77 tracing::info!("Render graph demo initialized");
78
79 Box::new(RenderGraphDemo {
80 _context: graphics_ctx,
81 window,
82 window_id,
83 })
84 });
85}29fn main() {
30 logging::init();
31
32 run_app(|ctx| {
33 let graphics_ctx = GraphicsContext::new_owned_sync_or_panic();
34
35 let window = ctx
36 .create_window(WindowDescriptor {
37 title: "Mesh Primitives Demo - Geometry API".to_string(),
38 size: Some(WinitPhysicalSize::new(1024.0, 768.0)),
39 ..Default::default()
40 })
41 .expect("Failed to create window");
42
43 let window = RenderableWindow::new_with_descriptor(
44 window,
45 graphics_ctx.clone(),
46 WindowContextDescriptor {
47 format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
48 ..Default::default()
49 },
50 ).expect("Failed to create renderable window");
51
52 let window_id = window.id();
53
54 println!("\n═══════════════════════════════════════════════════════");
55 println!(" 📐 MESH PRIMITIVES DEMO - Geometry API");
56 println!("═══════════════════════════════════════════════════════");
57 println!("\n MESH API FEATURES:");
58 println!(" • MeshBuilder for custom geometry");
59 println!(" • Primitive generation (cube, sphere, plane, etc.)");
60 println!(" • Flexible vertex formats (Position, Normal, UV, Color)");
61 println!(" • Index buffer optimization");
62 println!(" • Instanced rendering support");
63 println!("\n EXAMPLE PRIMITIVES:");
64 println!(" • Cube - box with 24 vertices (6 faces × 4 vertices)");
65 println!(" • Sphere - tessellated sphere with UV mapping");
66 println!(" • Plane - quad with optional subdivisions");
67 println!(" • Cylinder - sides + caps");
68 println!(" • Custom - arbitrary vertex/index data");
69 println!("\n Mesh API Usage:");
70 println!(" let mesh = MeshBuilder::new()");
71 println!(" .with_positions(vertices)");
72 println!(" .with_normals(normals)");
73 println!(" .with_uvs(uvs)");
74 println!(" .with_indices(indices)");
75 println!(" .build(&ctx);");
76 println!(" mesh.draw(&mut pass);");
77 println!(" mesh.draw_instanced(&mut pass, instance_count);");
78 println!("═══════════════════════════════════════════════════════\n");
79
80 tracing::info!("Mesh primitives demo initialized");
81
82 Box::new(MeshPrimitivesDemo {
83 _context: graphics_ctx,
84 window,
85 window_id,
86 })
87 });
88}Sourcepub async fn new_owned_with_descriptor(
descriptor: GraphicsContextDescriptor,
) -> Result<Arc<Self>, GraphicsError>
pub async fn new_owned_with_descriptor( descriptor: GraphicsContextDescriptor, ) -> Result<Arc<Self>, GraphicsError>
Creates a new graphics context with custom descriptor (owned).
Sourcepub fn info(&self) -> AdapterInfo
pub fn info(&self) -> AdapterInfo
Get device info
Examples found in repository?
29fn main() {
30 logging::init();
31
32 run_app(|ctx| {
33 let graphics_ctx = GraphicsContext::new_owned_sync_or_panic();
34 let renderer = Renderer::new(graphics_ctx.clone());
35
36 let window = ctx
37 .create_window(WindowDescriptor {
38 title: "Renderer API Example".to_string(),
39 size: Some(WinitPhysicalSize::new(800.0, 600.0)),
40 ..Default::default()
41 })
42 .expect("Failed to create window");
43
44 let window = RenderableWindow::new_with_descriptor(
45 window,
46 graphics_ctx.clone(),
47 WindowContextDescriptor {
48 format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
49 ..Default::default()
50 },
51 ).expect("Failed to create renderable window");
52
53 let window_id = window.id();
54
55 // Create shader using Renderer API
56 let shader = renderer.create_shader(Some("Color Shader"), SHADER_SOURCE);
57
58 // Create texture using Renderer helper
59 let texture_data = create_gradient_texture();
60 let texture = renderer.create_texture_2d(
61 Some("Gradient Texture"),
62 256,
63 256,
64 wgpu::TextureFormat::Rgba8UnormSrgb,
65 wgpu::TextureUsages::TEXTURE_BINDING,
66 &texture_data,
67 );
68
69 let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
70 let sampler = renderer.create_linear_sampler(Some("Linear Sampler"));
71
72 // Create bind group using Renderer API
73 let bind_group_layout = renderer.create_bind_group_layout(
74 Some("Texture Bind Group Layout"),
75 &[
76 wgpu::BindGroupLayoutEntry {
77 binding: 0,
78 visibility: wgpu::ShaderStages::FRAGMENT,
79 ty: wgpu::BindingType::Texture {
80 multisampled: false,
81 view_dimension: wgpu::TextureViewDimension::D2,
82 sample_type: wgpu::TextureSampleType::Float { filterable: true },
83 },
84 count: None,
85 },
86 wgpu::BindGroupLayoutEntry {
87 binding: 1,
88 visibility: wgpu::ShaderStages::FRAGMENT,
89 ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
90 count: None,
91 },
92 ],
93 );
94
95 let bind_group = renderer.create_bind_group(
96 Some("Texture Bind Group"),
97 &bind_group_layout,
98 &[
99 wgpu::BindGroupEntry {
100 binding: 0,
101 resource: wgpu::BindingResource::TextureView(&texture_view),
102 },
103 wgpu::BindGroupEntry {
104 binding: 1,
105 resource: wgpu::BindingResource::Sampler(&sampler),
106 },
107 ],
108 );
109
110 let pipeline_layout = renderer.create_pipeline_layout(
111 Some("Render Pipeline Layout"),
112 &[&bind_group_layout],
113 &[],
114 );
115
116 // Create pipeline using Renderer API with BlendMode
117 let pipeline = renderer.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
118 label: Some("Render Pipeline"),
119 layout: Some(&pipeline_layout),
120 vertex: wgpu::VertexState {
121 module: &shader,
122 entry_point: Some("vs_main"),
123 buffers: &[wgpu::VertexBufferLayout {
124 array_stride: 4 * 4,
125 step_mode: wgpu::VertexStepMode::Vertex,
126 attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2],
127 }],
128 compilation_options: wgpu::PipelineCompilationOptions::default(),
129 },
130 fragment: Some(wgpu::FragmentState {
131 module: &shader,
132 entry_point: Some("fs_main"),
133 // Use BlendMode for transparent rendering
134 targets: &[Some(
135 BlendMode::Alpha.to_color_target_state(wgpu::TextureFormat::Rgba8UnormSrgb),
136 )],
137 compilation_options: wgpu::PipelineCompilationOptions::default(),
138 }),
139 primitive: wgpu::PrimitiveState {
140 topology: wgpu::PrimitiveTopology::TriangleList,
141 strip_index_format: None,
142 front_face: wgpu::FrontFace::Ccw,
143 cull_mode: Some(wgpu::Face::Back),
144 polygon_mode: wgpu::PolygonMode::Fill,
145 unclipped_depth: false,
146 conservative: false,
147 },
148 depth_stencil: None,
149 multisample: wgpu::MultisampleState {
150 count: 1,
151 mask: !0,
152 alpha_to_coverage_enabled: false,
153 },
154 multiview: None,
155 cache: None,
156 });
157
158 #[rustfmt::skip]
159 let vertices: &[f32] = &[
160 -0.8, -0.8, 0.0, 1.0,
161 0.8, -0.8, 1.0, 1.0,
162 0.8, 0.8, 1.0, 0.0,
163 -0.8, -0.8, 0.0, 1.0,
164 0.8, 0.8, 1.0, 0.0,
165 -0.8, 0.8, 0.0, 0.0,
166 ];
167
168 // Create vertex buffer using Renderer helper
169 let vertex_buffer = renderer.create_vertex_buffer(Some("Vertex Buffer"), vertices);
170
171 // Create offscreen framebuffer using the new Framebuffer abstraction
172 let offscreen_fb = Framebuffer::builder(400, 300)
173 .format(wgpu::TextureFormat::Rgba8UnormSrgb)
174 .label("Offscreen FB")
175 .build(&graphics_ctx);
176
177 // Create blit shader and pipeline for rendering framebuffer to surface
178 let blit_shader = renderer.create_shader(Some("Blit Shader"), BLIT_SHADER_SOURCE);
179
180 let blit_bind_group_layout = renderer.create_bind_group_layout(
181 Some("Blit Bind Group Layout"),
182 &[
183 wgpu::BindGroupLayoutEntry {
184 binding: 0,
185 visibility: wgpu::ShaderStages::FRAGMENT,
186 ty: wgpu::BindingType::Texture {
187 multisampled: false,
188 view_dimension: wgpu::TextureViewDimension::D2,
189 sample_type: wgpu::TextureSampleType::Float { filterable: true },
190 },
191 count: None,
192 },
193 wgpu::BindGroupLayoutEntry {
194 binding: 1,
195 visibility: wgpu::ShaderStages::FRAGMENT,
196 ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
197 count: None,
198 },
199 ],
200 );
201
202 let blit_bind_group = renderer.create_bind_group(
203 Some("Blit Bind Group"),
204 &blit_bind_group_layout,
205 &[
206 wgpu::BindGroupEntry {
207 binding: 0,
208 resource: wgpu::BindingResource::TextureView(offscreen_fb.color_view()),
209 },
210 wgpu::BindGroupEntry {
211 binding: 1,
212 resource: wgpu::BindingResource::Sampler(&sampler),
213 },
214 ],
215 );
216
217 let blit_pipeline_layout = renderer.create_pipeline_layout(
218 Some("Blit Pipeline Layout"),
219 &[&blit_bind_group_layout],
220 &[],
221 );
222
223 let blit_pipeline = renderer.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
224 label: Some("Blit Pipeline"),
225 layout: Some(&blit_pipeline_layout),
226 vertex: wgpu::VertexState {
227 module: &blit_shader,
228 entry_point: Some("vs_main"),
229 buffers: &[],
230 compilation_options: wgpu::PipelineCompilationOptions::default(),
231 },
232 fragment: Some(wgpu::FragmentState {
233 module: &blit_shader,
234 entry_point: Some("fs_main"),
235 // Use PremultipliedAlpha for framebuffer blitting
236 targets: &[Some(
237 BlendMode::PremultipliedAlpha
238 .to_color_target_state(wgpu::TextureFormat::Bgra8UnormSrgb),
239 )],
240 compilation_options: wgpu::PipelineCompilationOptions::default(),
241 }),
242 primitive: wgpu::PrimitiveState {
243 topology: wgpu::PrimitiveTopology::TriangleList,
244 ..Default::default()
245 },
246 depth_stencil: None,
247 multisample: wgpu::MultisampleState::default(),
248 multiview: None,
249 cache: None,
250 });
251
252 tracing::info!("Renderer initialized successfully");
253 tracing::info!("Device: {:?}", renderer.context().info());
254
255 Box::new(RendererApp {
256 context: graphics_ctx,
257 renderer,
258 window,
259 window_id,
260 pipeline,
261 bind_group,
262 vertex_buffer,
263 offscreen_fb,
264 blit_pipeline,
265 blit_bind_group,
266 time: 0.0,
267 })
268 });
269}Sourcepub fn wgpu_features(&self) -> Features
pub fn wgpu_features(&self) -> Features
Get raw wgpu device features
Sourcepub fn gpu_features(&self) -> GpuFeatures
pub fn gpu_features(&self) -> GpuFeatures
Get the enabled GPU features (high-level wrapper).
Sourcepub fn has_feature(&self, feature: GpuFeatures) -> bool
pub fn has_feature(&self, feature: GpuFeatures) -> bool
Check if a specific GPU feature is enabled.
Sourcepub fn has_all_features(&self, features: GpuFeatures) -> bool
pub fn has_all_features(&self, features: GpuFeatures) -> bool
Check if all specified GPU features are enabled.
Sourcepub fn require_feature(&self, feature: GpuFeatures)
pub fn require_feature(&self, feature: GpuFeatures)
Assert that a feature is available, panicking with a clear message if not.
Use this before operations that require specific features.
Sourcepub fn supports_texture_format(
&self,
format: TextureFormat,
usages: TextureUsages,
) -> bool
pub fn supports_texture_format( &self, format: TextureFormat, usages: TextureUsages, ) -> bool
Sourcepub fn texture_format_capabilities(
&self,
format: TextureFormat,
) -> TextureFormatFeatures
pub fn texture_format_capabilities( &self, format: TextureFormat, ) -> TextureFormatFeatures
Get texture format capabilities.
Returns detailed information about what operations are supported for a given texture format.
Sourcepub fn max_texture_dimension_2d(&self) -> u32
pub fn max_texture_dimension_2d(&self) -> u32
Get the maximum 2D texture dimension.
This is the maximum width and height for 2D textures.
Sourcepub fn max_buffer_size(&self) -> u64
pub fn max_buffer_size(&self) -> u64
Get the maximum buffer size in bytes.
This is the maximum size for any buffer.
Sourcepub fn min_uniform_buffer_offset_alignment(&self) -> u32
pub fn min_uniform_buffer_offset_alignment(&self) -> u32
Get the minimum uniform buffer offset alignment.
When using dynamic uniform buffers, offsets must be aligned to this value.
Sourcepub fn min_storage_buffer_offset_alignment(&self) -> u32
pub fn min_storage_buffer_offset_alignment(&self) -> u32
Get the minimum storage buffer offset alignment.
When using dynamic storage buffers, offsets must be aligned to this value.
Sourcepub fn max_push_constant_size(&self) -> u32
pub fn max_push_constant_size(&self) -> u32
Get the maximum push constant size in bytes.
Push constants require the PUSH_CONSTANTS feature.
Returns 0 if push constants are not supported.
Sourcepub fn max_texture_dimension_1d(&self) -> u32
pub fn max_texture_dimension_1d(&self) -> u32
Get the maximum 1D texture dimension.
Sourcepub fn max_texture_dimension_3d(&self) -> u32
pub fn max_texture_dimension_3d(&self) -> u32
Get the maximum 3D texture dimension.
Sourcepub fn max_texture_array_layers(&self) -> u32
pub fn max_texture_array_layers(&self) -> u32
Get the maximum texture array layers.
Sourcepub fn max_bind_groups(&self) -> u32
pub fn max_bind_groups(&self) -> u32
Get the maximum bind groups.
Sourcepub fn max_bindings_per_bind_group(&self) -> u32
pub fn max_bindings_per_bind_group(&self) -> u32
Get the maximum bindings per bind group.
Sourcepub fn max_dynamic_uniform_buffers_per_pipeline_layout(&self) -> u32
pub fn max_dynamic_uniform_buffers_per_pipeline_layout(&self) -> u32
Get the maximum dynamic uniform buffers per pipeline layout.
Sourcepub fn max_dynamic_storage_buffers_per_pipeline_layout(&self) -> u32
pub fn max_dynamic_storage_buffers_per_pipeline_layout(&self) -> u32
Get the maximum dynamic storage buffers per pipeline layout.
Sourcepub fn max_sampled_textures_per_shader_stage(&self) -> u32
pub fn max_sampled_textures_per_shader_stage(&self) -> u32
Get the maximum sampled textures per shader stage.
Sourcepub fn max_samplers_per_shader_stage(&self) -> u32
pub fn max_samplers_per_shader_stage(&self) -> u32
Get the maximum samplers per shader stage.
Sourcepub fn max_storage_buffers_per_shader_stage(&self) -> u32
pub fn max_storage_buffers_per_shader_stage(&self) -> u32
Get the maximum storage buffers per shader stage.
Sourcepub fn max_storage_textures_per_shader_stage(&self) -> u32
pub fn max_storage_textures_per_shader_stage(&self) -> u32
Get the maximum storage textures per shader stage.
Sourcepub fn max_uniform_buffers_per_shader_stage(&self) -> u32
pub fn max_uniform_buffers_per_shader_stage(&self) -> u32
Get the maximum uniform buffers per shader stage.
Sourcepub fn max_uniform_buffer_binding_size(&self) -> u32
pub fn max_uniform_buffer_binding_size(&self) -> u32
Get the maximum uniform buffer binding size.
Sourcepub fn max_storage_buffer_binding_size(&self) -> u32
pub fn max_storage_buffer_binding_size(&self) -> u32
Get the maximum storage buffer binding size.
Sourcepub fn max_vertex_buffers(&self) -> u32
pub fn max_vertex_buffers(&self) -> u32
Get the maximum vertex buffers.
Sourcepub fn max_vertex_attributes(&self) -> u32
pub fn max_vertex_attributes(&self) -> u32
Get the maximum vertex attributes.
Sourcepub fn max_vertex_buffer_array_stride(&self) -> u32
pub fn max_vertex_buffer_array_stride(&self) -> u32
Get the maximum vertex buffer array stride.
Sourcepub fn max_compute_workgroup_storage_size(&self) -> u32
pub fn max_compute_workgroup_storage_size(&self) -> u32
Get the maximum compute workgroup storage size.
Sourcepub fn max_compute_invocations_per_workgroup(&self) -> u32
pub fn max_compute_invocations_per_workgroup(&self) -> u32
Get the maximum compute invocations per workgroup.
Sourcepub fn max_compute_workgroup_size_x(&self) -> u32
pub fn max_compute_workgroup_size_x(&self) -> u32
Get the maximum compute workgroup size X.
Sourcepub fn max_compute_workgroup_size_y(&self) -> u32
pub fn max_compute_workgroup_size_y(&self) -> u32
Get the maximum compute workgroup size Y.
Sourcepub fn max_compute_workgroup_size_z(&self) -> u32
pub fn max_compute_workgroup_size_z(&self) -> u32
Get the maximum compute workgroup size Z.
Sourcepub fn max_compute_workgroups_per_dimension(&self) -> u32
pub fn max_compute_workgroups_per_dimension(&self) -> u32
Get the maximum compute workgroups per dimension.
Trait Implementations§
Source§impl AsWgpu for GraphicsContext
impl AsWgpu for GraphicsContext
Source§impl GraphicsContextExt for GraphicsContext
impl GraphicsContextExt for GraphicsContext
Source§impl RenderContext for GraphicsContext
impl RenderContext for GraphicsContext
Source§fn create_buffer(&self, desc: &BufferDescriptor<'_>) -> GpuBuffer
fn create_buffer(&self, desc: &BufferDescriptor<'_>) -> GpuBuffer
Source§fn write_buffer(&self, buffer: &GpuBuffer, offset: u64, data: &[u8])
fn write_buffer(&self, buffer: &GpuBuffer, offset: u64, data: &[u8])
Source§fn create_texture(&self, desc: &TextureDescriptor<'_>) -> GpuTexture
fn create_texture(&self, desc: &TextureDescriptor<'_>) -> GpuTexture
Source§fn create_shader_module(
&self,
desc: &ShaderModuleDescriptor<'_>,
) -> GpuShaderModule
fn create_shader_module( &self, desc: &ShaderModuleDescriptor<'_>, ) -> GpuShaderModule
Source§fn create_render_pipeline(
&self,
desc: &RenderPipelineDescriptor<'_>,
) -> GpuRenderPipeline
fn create_render_pipeline( &self, desc: &RenderPipelineDescriptor<'_>, ) -> GpuRenderPipeline
Source§fn create_compute_pipeline(
&self,
desc: &ComputePipelineDescriptor<'_>,
) -> GpuComputePipeline
fn create_compute_pipeline( &self, desc: &ComputePipelineDescriptor<'_>, ) -> GpuComputePipeline
Source§fn create_bind_group_layout(
&self,
desc: &BindGroupLayoutDescriptor<'_>,
) -> GpuBindGroupLayout
fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor<'_>, ) -> GpuBindGroupLayout
Source§fn create_bind_group(&self, desc: &BindGroupDescriptor<'_>) -> GpuBindGroup
fn create_bind_group(&self, desc: &BindGroupDescriptor<'_>) -> GpuBindGroup
Source§fn create_sampler(&self, desc: &SamplerDescriptor<'_>) -> GpuSampler
fn create_sampler(&self, desc: &SamplerDescriptor<'_>) -> GpuSampler
Auto Trait Implementations§
impl Freeze for GraphicsContext
impl !RefUnwindSafe for GraphicsContext
impl Send for GraphicsContext
impl Sync for GraphicsContext
impl Unpin for GraphicsContext
impl !UnwindSafe for GraphicsContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more