Skip to content

Commit 2146029

Browse files
committed
hlsl_generator: fix formatting and add use is_pointer_v for bitcast
Signed-off-by: Ali Cheraghi <[email protected]>
1 parent 20034bb commit 2146029

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

tools/hlsl_generator/gen.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@
3939
4040
//! Std 450 Extended set operations
4141
template<typename SquareMatrix>
42-
[[vk::ext_instruction(GLSLstd450MatrixInverse)]]
42+
[[vk::ext_instruction(34, /* GLSLstd450MatrixInverse */, "GLSL.std.450")]]
4343
SquareMatrix matrixInverse(NBL_CONST_REF_ARG(SquareMatrix) mat);
4444
4545
// Add specializations if you need to emit a `ext_capability` (this means that the instruction needs to forward through an `impl::` struct and so on)
4646
template<typename T, typename U>
4747
[[vk::ext_capability(spv::CapabilityPhysicalStorageBufferAddresses)]]
4848
[[vk::ext_instruction(spv::OpBitcast)]]
49-
enable_if_t<is_spirv_type_v<T> && is_spirv_type_v<U>, T> bitcast(U);
49+
enable_if_t<is_pointer_v<T>, T> bitcast(U);
5050
5151
template<typename T>
5252
[[vk::ext_capability(spv::CapabilityPhysicalStorageBufferAddresses)]]
5353
[[vk::ext_instruction(spv::OpBitcast)]]
54-
uint64_t bitcast(pointer_t<spv::StorageClassPhysicalStorageBuffer,T>);
54+
uint64_t bitcast(pointer_t<spv::StorageClassPhysicalStorageBuffer, T>);
5555
5656
template<typename T>
5757
[[vk::ext_capability(spv::CapabilityPhysicalStorageBufferAddresses)]]
5858
[[vk::ext_instruction(spv::OpBitcast)]]
59-
pointer_t<spv::StorageClassPhysicalStorageBuffer,T> bitcast(uint64_t);
59+
pointer_t<spv::StorageClassPhysicalStorageBuffer, T> bitcast(uint64_t);
6060
6161
template<class T, class U>
6262
[[vk::ext_instruction(spv::OpBitcast)]]
@@ -86,7 +86,7 @@ def gen(grammer_path, output_path):
8686
with output as writer:
8787
writer.write(head)
8888

89-
writer.write("\n//! Builtins\nnamespace builtin\n{")
89+
writer.write("\n//! Builtins\nnamespace builtin\n{\n")
9090
for b in builtins:
9191
builtin_type = None
9292
is_output = False

tools/hlsl_generator/out.hlsl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,33 @@ pointer_t<StorageClass, T> copyObject([[vk::ext_reference]] T value);
3030

3131
//! Std 450 Extended set operations
3232
template<typename SquareMatrix>
33-
[[vk::ext_instruction(GLSLstd450MatrixInverse)]]
33+
[[vk::ext_instruction(34, /* GLSLstd450MatrixInverse */, "GLSL.std.450")]]
3434
SquareMatrix matrixInverse(NBL_CONST_REF_ARG(SquareMatrix) mat);
3535

3636
// Add specializations if you need to emit a `ext_capability` (this means that the instruction needs to forward through an `impl::` struct and so on)
3737
template<typename T, typename U>
3838
[[vk::ext_capability(spv::CapabilityPhysicalStorageBufferAddresses)]]
3939
[[vk::ext_instruction(spv::OpBitcast)]]
40-
enable_if_t<is_spirv_type_v<T> && is_spirv_type_v<U>, T> bitcast(U);
40+
enable_if_t<is_pointer_v<T>, T> bitcast(U);
4141

4242
template<typename T>
4343
[[vk::ext_capability(spv::CapabilityPhysicalStorageBufferAddresses)]]
4444
[[vk::ext_instruction(spv::OpBitcast)]]
45-
uint64_t bitcast(pointer_t<spv::StorageClassPhysicalStorageBuffer,T>);
45+
uint64_t bitcast(pointer_t<spv::StorageClassPhysicalStorageBuffer, T>);
4646

4747
template<typename T>
4848
[[vk::ext_capability(spv::CapabilityPhysicalStorageBufferAddresses)]]
4949
[[vk::ext_instruction(spv::OpBitcast)]]
50-
pointer_t<spv::StorageClassPhysicalStorageBuffer,T> bitcast(uint64_t);
50+
pointer_t<spv::StorageClassPhysicalStorageBuffer, T> bitcast(uint64_t);
5151

5252
template<class T, class U>
5353
[[vk::ext_instruction(spv::OpBitcast)]]
5454
T bitcast(U);
5555

5656
//! Builtins
5757
namespace builtin
58-
{[[vk::ext_builtin_output(spv::BuiltInPosition)]]
58+
{
59+
[[vk::ext_builtin_output(spv::BuiltInPosition)]]
5960
static float32_t4 Position;
6061
[[vk::ext_builtin_input(spv::BuiltInHelperInvocation)]]
6162
static const bool HelperInvocation;

0 commit comments

Comments
 (0)