-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drawing vertices without vertex buffer not possible with OpenGL #2342
Comments
Here is a renderdoc log: And a spectorjs log: |
Alright, so I noticed that the issue is not the rendering code, but my shader. It works if I move the VERTICES array into the main(): [[stage(vertex)]]
fn main(
//[[location(0)]] a_position: vec2<f32>,
[[location(4)]] mask_offset: vec2<f32>,
[[location(5)]] target_width: f32,
[[location(6)]] target_height: f32,
[[location(7)]] debug_color: vec4<f32>,
[[builtin(vertex_index)]] vertex_idx: u32,
[[builtin(instance_index)]] instance_idx: u32 // instance_index is used when we have multiple instances of the same "object"
) -> VertexOutput {
var VERTICES: array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(0.0, 0.0),
vec2<f32>(0.0, EXTENT),
vec2<f32>(EXTENT, 0.0),
vec2<f32>(EXTENT, 0.0),
vec2<f32>(0.0, EXTENT),
vec2<f32>(EXTENT, EXTENT)
);
var a_position = VERTICES[vertex_idx];
// Encode a square within the shader
let scaling: mat3x3<f32> = mat3x3<f32>(
vec3<f32>(target_width, 0.0, 0.0),
vec3<f32>(0.0, target_height, 0.0),
vec3<f32>(0.0, 0.0, 1.0)
);
let z = 0.0;
let world_pos_3d = vec3<f32>(a_position + mask_offset, z);
let world_pos = scaling * world_pos_3d;
let position = globals.camera.view_proj * vec4<f32>(world_pos, 1.0);
return VertexOutput(debug_color, position);
} |
Closed in favor of gfx-rs/naga#1638 |
cwfitzgerald
pushed a commit
that referenced
this issue
Oct 25, 2023
* error on param redefinition * also fix #2312
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I'm drawing several instances of vertices which are statically defined in a vertex shader. I'm drawing 7 instances of 6 vertices like in the following. The data for each instance is bound to slot 0.
This works nicely on Vulkan. I get 7 squares with the vertex shader below. On OpenGL and WebGL nothing is drawn.
WGSL shader:
Repro steps
None right now.
Expected vs observed behavior
Right now nothing is drawn with OpenGL. I would expect that drawing without a vertex buffer works with OpenGL.
Extra materials
None
Platform
wgpu: 0.12 (latest)
OpenGL: ES 3.2 Mesa 21.3.2
The text was updated successfully, but these errors were encountered: