-
Notifications
You must be signed in to change notification settings - Fork 0
Dev bindgroup set #26
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
Changes from all commits
d1fcac9
5453d5f
2157bd1
7fc6c84
ed2aea7
241a16e
20e5186
cc629b3
2ab7beb
6de4c2a
b639613
fdd873c
3e5cad8
ace73c9
c68713f
eb12122
898c27d
a3b4231
0fb4add
d0c7c05
7cdc1bf
f6593ad
7c6e35a
3b5e82a
20cb98a
6b7cead
283e966
0d51e10
4c78336
8e04a00
e42939c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #include <iostream> | ||
| #include <map> | ||
| #include <memory> | ||
|
|
||
| #include "bindgroup_set_impl.hpp" | ||
|
|
||
| namespace dawn_wrapper { | ||
| bindgroup_set::bindgroup_set() | ||
| : m_pimpl(std::make_shared<bindgroup_set::pimpl>()) | ||
| { | ||
| } | ||
|
|
||
| bindgroup_set& bindgroup_set::add_bindgroup(bindgroup_wrapper bg, unsigned group) | ||
| { | ||
| m_pimpl->add_bindgroup(bg, group); | ||
| return *this; | ||
| } | ||
|
|
||
| } // dawn_wrapper |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #pragma once | ||
|
|
||
| #include "buffer_wrapper_impl.hpp" | ||
| #include "texture_output_wrapper_impl.hpp" | ||
| #include "texture_wrapper_impl.hpp" | ||
|
|
||
| #include <map> | ||
| #include <string> | ||
|
|
||
| using namespace wgpu; | ||
|
|
||
| namespace dawn_wrapper { | ||
|
|
||
| struct bindgroup_set::pimpl { | ||
|
|
||
| void add_bindgroup(bindgroup_wrapper bg, unsigned group) | ||
| { | ||
| m_bindgroups[group] = bg; | ||
| } | ||
|
|
||
| pimpl() | ||
| : m_bindgroups() | ||
| { | ||
| } | ||
|
|
||
| std::map<unsigned, bindgroup_wrapper> m_bindgroups; | ||
| }; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #pragma once | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "bindgroup_layout_wrapper_impl.hpp" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "bindgroup_set_impl.hpp" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "bindgroup_wrapper_impl.hpp" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "encoder_wrapper_impl.hpp" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "shader_base.hpp" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -50,6 +51,32 @@ struct render_wrapper::pimpl : private shader_base { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return m_surface.m_pimpl->getCurrentTextureView(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void render(bindgroup_set set, encoder_wrapper encoder) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto textureView = getCurrentTextureView(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT(textureView); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto pass = dawn_utils::begin_render_pass(encoder.m_pimpl->m_encoder, textureView); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass.SetPipeline(get_pipeline()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (auto entry : set.m_pimpl->m_bindgroups) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT(entry.second.m_pimpl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass.SetBindGroup(entry.first, entry.second.m_pimpl->make_bindgroup(m_device)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard Line 64 dereferences 🛠️ Proposed fix void render(bindgroup_set set, encoder_wrapper encoder)
{
ASSERT(m_bindGroupLayout);
+ ASSERT(set.is_valid());
auto textureView = getCurrentTextureView();
ASSERT(textureView);
auto pass = dawn_utils::begin_render_pass(encoder.m_pimpl->m_encoder, textureView);
pass.SetPipeline(get_pipeline());
- for (auto entry : set.m_pimpl->m_bindgroups)
+ for (const auto& entry : set.m_pimpl->m_bindgroups)
{
+ ASSERT(entry.second.is_valid());
pass.SetBindGroup(entry.first, entry.second.m_pimpl->make_bindgroup(m_device));
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass.SetVertexBuffer(0, get_bufferVertex(), 0, get_bufferVertex().GetSize()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass.SetIndexBuffer(get_bufferIndex(), IndexFormat::Uint16, 0, get_bufferIndex().GetSize()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass.DrawIndexed(3, 1, 0, 0, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass.End(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| encoder.submit_command_buffer(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifndef __EMSCRIPTEN__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_surface.present(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void render(bindgroup_wrapper bindGroup, encoder_wrapper encoder) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT(m_bindGroupLayout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -123,11 +150,6 @@ struct render_wrapper::pimpl : private shader_base { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return m_pipeline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BindGroupLayout get_bindGroupLayout() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return m_bindGroupLayout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Buffer get_bufferVertex() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return m_bufferVertex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.