Skip to content

Commit 13fa93a

Browse files
trivedivivekfacebook-github-bot
authored andcommitted
Using push constants for binary scalar op parameter.
Summary: The diff modifies the `BinaryScalarOp` implementation to utilize push constants for the scalar value parameter. Differential Revision: D88097606
1 parent ddd13d4 commit 13fa93a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

backends/vulkan/runtime/graph/ops/glsl/binary_scalar_buffer.glsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ ${layout_declare_tensor(B, "r", "t_in", DTYPE, STORAGE)}
2929
${layout_declare_ubo(B, "BufferMetadata", "outp")}
3030
${layout_declare_ubo(B, "BufferMetadata", "inp")}
3131

32-
${layout_declare_ubo(B, "float", "scalar_value")}
32+
layout(push_constant) uniform restrict Block {
33+
float scalar_value;
34+
};
3335

3436
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
3537

backends/vulkan/runtime/graph/ops/glsl/binary_scalar_texture.glsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ ${layout_declare_tensor(B, "r", "t_in", DTYPE, STORAGE)}
3030
${layout_declare_ubo(B, "TextureMetadata", "outp")}
3131
${layout_declare_ubo(B, "TextureMetadata", "inp")}
3232

33-
${layout_declare_ubo(B, "float", "scalar_value")}
33+
layout(push_constant) uniform restrict Block {
34+
float scalar_value;
35+
};
3436

3537
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
3638

backends/vulkan/runtime/graph/ops/impl/BinaryScalarOp.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ void add_binary_scalar_op_node(
5050

5151
vkapi::ParamsBindList param_ubos = {
5252
graph.meta_ubo(out),
53-
graph.meta_ubo(in),
54-
graph.create_params_buffer(scalar_val)};
53+
graph.meta_ubo(in)};
5554

5655
graph.execute_nodes().emplace_back(new DynamicDispatchNode(
5756
graph,
@@ -63,7 +62,7 @@ void add_binary_scalar_op_node(
6362
// Shader params buffers
6463
param_ubos,
6564
// Push Constants
66-
{},
65+
{PushConstantDataInfo(&scalar_val, sizeof(scalar_val))},
6766
// Specialization Constants
6867
{},
6968
// Resize Args

0 commit comments

Comments
 (0)