Skip to content

Commit f102f08

Browse files
committed
bla3
1 parent 6c32cb7 commit f102f08

File tree

7 files changed

+47
-11
lines changed

7 files changed

+47
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ glam = { version = "0.30.9", default-features = false }
3232
bytemuck = { version = "1.24.0", features = ["derive"] }
3333
raw-window-handle = "0.6.2"
3434
winit = "0.30.0"
35-
cfg-if = "1.0.0"
35+
env_logger = "0.11.8"
3636
anyhow = "1.0.98"

graphics/Cargo.toml.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ glam = { version = "0.30.9", default-features = false }
4141
bytemuck = { version = "1.24.0", features = ["derive"] }
4242
raw-window-handle = "0.6.2"
4343
winit = "0.30.0"
44-
cfg-if = "1.0.0"
44+
env_logger = "0.11.8"
4545
anyhow = "1.0.98"
4646

4747
{% if integration == "spirv-builder" -%}

graphics/mygraphics/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ash.workspace = true
1919
ash-window.workspace = true
2020
wgpu.workspace = true
2121
pollster.workspace = true
22+
env_logger.workspace = true
2223

2324
# other
2425
raw-window-handle.workspace = true

graphics/mygraphics/Cargo.toml.liquid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ash-window.workspace = true
2929
{%- if api == "wgpu" -%}
3030
wgpu.workspace = true
3131
pollster.workspace = true
32+
env_logger.workspace = true
3233
{%- endif %}
3334

3435
# other

graphics/mygraphics/src/wgpu_renderer/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mod renderer;
1010
mod swapchain;
1111

1212
pub fn main() -> anyhow::Result<()> {
13+
env_logger::init();
1314
pollster::block_on(main_inner())
1415
}
1516

@@ -35,7 +36,8 @@ pub async fn main_inner() -> anyhow::Result<()> {
3536
let adapter =
3637
wgpu::util::initialize_adapter_from_env_or_default(&instance, Some(&surface)).await?;
3738

38-
let required_features = wgpu::Features::PUSH_CONSTANTS;
39+
let required_features =
40+
wgpu::Features::PUSH_CONSTANTS | wgpu::Features::EXPERIMENTAL_PASSTHROUGH_SHADERS;
3941
let required_limits = wgpu::Limits {
4042
max_push_constant_size: 128,
4143
..Default::default()
@@ -45,7 +47,7 @@ pub async fn main_inner() -> anyhow::Result<()> {
4547
label: None,
4648
required_features,
4749
required_limits,
48-
experimental_features: wgpu::ExperimentalFeatures::disabled(),
50+
experimental_features: unsafe { wgpu::ExperimentalFeatures::enabled() },
4951
memory_hints: wgpu::MemoryHints::Performance,
5052
trace: Default::default(),
5153
})

graphics/mygraphics/src/wgpu_renderer/render_pipeline.rs

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use mygraphics_shaders::ShaderConstants;
22
use wgpu::{
3-
ColorTargetState, ColorWrites, Device, FragmentState, FrontFace, MultisampleState, PolygonMode,
4-
PrimitiveState, PrimitiveTopology, RenderPass, RenderPipeline, RenderPipelineDescriptor,
5-
ShaderStages, TextureFormat, VertexState, include_spirv,
3+
ColorTargetState, ColorWrites, Device, FragmentState, FrontFace, MultisampleState,
4+
PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange,
5+
RenderPass, RenderPipeline, RenderPipelineDescriptor, ShaderModuleDescriptorPassthrough,
6+
ShaderRuntimeChecks, ShaderStages, TextureFormat, VertexState,
67
};
78

89
pub struct MyRenderPipeline {
@@ -11,14 +12,44 @@ pub struct MyRenderPipeline {
1112

1213
impl MyRenderPipeline {
1314
pub fn new(device: &Device, out_format: TextureFormat) -> anyhow::Result<Self> {
14-
let module = device.create_shader_module(include_spirv!(env!("SHADER_SPV_PATH")));
15+
// Workaround in wgpu 27.0.1 where the macro expansion of `include_spirv_raw!` doesn't compile
16+
// see https://github.com/gfx-rs/wgpu/pull/8250
17+
// let module = unsafe {
18+
// device.create_shader_module_passthrough(include_spirv_raw!(env!("SHADER_SPV_PATH")))
19+
// };
20+
let module = unsafe {
21+
device.create_shader_module_passthrough(ShaderModuleDescriptorPassthrough {
22+
label: Some(env!("SHADER_SPV_PATH")),
23+
entry_point: "".to_owned(),
24+
num_workgroups: (0, 0, 0),
25+
runtime_checks: ShaderRuntimeChecks::unchecked(),
26+
spirv: Some(wgpu::util::make_spirv_raw(include_bytes!(env!(
27+
"SHADER_SPV_PATH"
28+
)))),
29+
dxil: None,
30+
msl: None,
31+
hlsl: None,
32+
glsl: None,
33+
wgsl: None,
34+
})
35+
};
36+
37+
let layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
38+
label: Some("MyRenderPipeline layout"),
39+
bind_group_layouts: &[],
40+
push_constant_ranges: &[PushConstantRange {
41+
stages: ShaderStages::VERTEX_FRAGMENT,
42+
range: 0..size_of::<ShaderConstants>() as u32,
43+
}],
44+
});
45+
1546
Ok(Self {
1647
pipeline: device.create_render_pipeline(&RenderPipelineDescriptor {
1748
label: Some("MyRenderPipeline"),
18-
layout: None,
49+
layout: Some(&layout),
1950
vertex: VertexState {
2051
module: &module,
21-
entry_point: None,
52+
entry_point: Some("main_vs"),
2253
compilation_options: Default::default(),
2354
buffers: &[],
2455
},
@@ -35,7 +66,7 @@ impl MyRenderPipeline {
3566
multisample: MultisampleState::default(),
3667
fragment: Some(FragmentState {
3768
module: &module,
38-
entry_point: None,
69+
entry_point: Some("main_fs"),
3970
compilation_options: Default::default(),
4071
targets: &[Some(ColorTargetState {
4172
format: out_format,

0 commit comments

Comments
 (0)