-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Root/Push constants #22
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -732,6 +732,16 @@ void DXCommandList::ResolveQueryData(const std::shared_ptr<QueryHeap>& query_hea | |
D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0)); | ||
} | ||
|
||
void DXCommandList::SetGraphicsConstant(uint32_t root_parameter_index, uint32_t value, uint32_t byte_offset) | ||
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. In the current implementation, how do you know which 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. The root parameter index is the index of the binding set/layout set in the list given to CreateBindingSetLayout or CreateBindingSet. |
||
{ | ||
m_command_list->SetGraphicsRoot32BitConstant(root_parameter_index, value, byte_offset); | ||
} | ||
|
||
void DXCommandList::SetComputeConstant(uint32_t root_parameter_index, uint32_t value, uint32_t byte_offset) | ||
{ | ||
m_command_list->SetComputeRoot32BitConstant(root_parameter_index, value, byte_offset); | ||
} | ||
|
||
ComPtr<ID3D12GraphicsCommandList> DXCommandList::GetCommandList() | ||
{ | ||
return m_command_list; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -766,6 +766,22 @@ void VKCommandList::ResolveQueryData(const std::shared_ptr<QueryHeap>& query_hea | |
vk::QueryResultFlagBits::eWait); | ||
} | ||
|
||
void VKCommandList::SetGraphicsConstant(uint32_t root_parameter_index, uint32_t value, uint32_t byte_offset) | ||
{ | ||
decltype(auto) pipeline_layout = m_state->GetPipelineLayout(); | ||
m_command_list->pushConstants(pipeline_layout, | ||
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. You also need to specify |
||
vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, | ||
byte_offset, | ||
sizeof(value), | ||
&value); | ||
} | ||
|
||
void VKCommandList::SetComputeConstant(uint32_t root_parameter_index, uint32_t value, uint32_t byte_offset) | ||
{ | ||
decltype(auto) pipeline_layout = m_state->GetPipelineLayout(); | ||
m_command_list->pushConstants(pipeline_layout, vk::ShaderStageFlagBits::eCompute, byte_offset, sizeof(value), &value); | ||
} | ||
|
||
void VKCommandList::SetName(const std::string& name) | ||
{ | ||
vk::DebugUtilsObjectNameInfoEXT info = {}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -408,6 +408,7 @@ struct BindKey { | |
uint32_t space = 0; | ||
uint32_t count = 1; | ||
uint32_t remapped_slot = ~0; | ||
bool is_root_constant = false; | ||
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. I suggest to use 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. Actually no, it's better to use But since we still need to pass the size for push_constant, it is better to pass it separately from the BindKey. 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. If I use 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. For example, we can separate them.
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. Not sure what is best to use, just ShaderType or BindKey.
|
||
|
||
uint32_t GetRemappedSlot() const | ||
{ | ||
|
@@ -419,7 +420,7 @@ struct BindKey { | |
|
||
auto MakeTie() const | ||
{ | ||
return std::tie(shader_type, view_type, slot, space, count); | ||
return std::tie(shader_type, view_type, slot, space, count, is_root_constant); | ||
} | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use PushConstants, to match it with
[[vk::push_constant]]
in hlsl.void PushConstants(ShaderType shader_type, uint32_t dst_offset, const void* data, uint32_t size)
In Vulkan we can have at most 1 push_constant block in each shader, I suggest to add the same limitation in FlyCube. In this case
ShaderType
+ activePipeline
will probably be enough to find root_parameter_index in DirectX12 implementation.In my opinion
PushConstants
is enough to for all cases, but I don't mind havingPushConstant
as well.void PushConstant(ShaderType shader_type, uint32_t dst_offset, uint32_t value)