Skip to content

[HLSL] Add Increment/DecrementCounter methods to structured buffers #117608

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

Merged
merged 23 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8c76f28
[HLSL] Add Increment/DecrementCounter methods to structured buffers
hekota Oct 29, 2024
a94c901
Code review feedback - add test & asserts, add Sema to main decl buil…
hekota Nov 1, 2024
eb26a6f
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 1, 2024
0f4c61f
Code review feedback - assert of completed definition or no method body
hekota Nov 5, 2024
f180391
clang-format
hekota Nov 5, 2024
942af76
Code review feedback - remove unused method, add comment
hekota Nov 5, 2024
8119cd0
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 6, 2024
ed6d0f9
Add Increment/DecrementCounter to RasterizerOrderedStructuredBuffer; …
hekota Nov 7, 2024
7fe5623
Remove accidentally added file; update builtin to not be Const
hekota Nov 7, 2024
d04755b
Add comments, make getResourceHandleExpr public, add const int helper…
hekota Nov 14, 2024
bc336cb
code review feedback
hekota Nov 14, 2024
730b80e
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 14, 2024
170e390
fix merge
hekota Nov 14, 2024
ba8be73
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 15, 2024
d8f3d9c
Update intrinsics name and arguments to match DXIL and SPIRV.
hekota Nov 21, 2024
6f2496c
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 21, 2024
6271433
Add bitcast from builtin i32 param to intrinsic's i8
hekota Nov 22, 2024
e3ad5e6
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 22, 2024
4b70b99
code review feedback, fix merge, remove unused addConceptSpecializati…
hekota Nov 23, 2024
00ad032
Rename S to SemaRef & clang-format
hekota Nov 23, 2024
b2ec3ad
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 23, 2024
8987697
Use std::abs and update test
hekota Nov 25, 2024
2787c47
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion clang/include/clang/Basic/Builtins.td
Original file line number Diff line number Diff line change
Expand Up @@ -4882,7 +4882,6 @@ def HLSLSaturate : LangBuiltin<"HLSL_LANG"> {
let Prototype = "void(...)";
}


def HLSLSelect : LangBuiltin<"HLSL_LANG"> {
let Spellings = ["__builtin_hlsl_select"];
let Attributes = [NoThrow, Const];
Expand All @@ -4907,6 +4906,12 @@ def HLSLRadians : LangBuiltin<"HLSL_LANG"> {
let Prototype = "void(...)";
}

def HLSLBufferUpdateCounter : LangBuiltin<"HLSL_LANG"> {
let Spellings = ["__builtin_hlsl_buffer_update_counter"];
let Attributes = [NoThrow];
let Prototype = "uint32_t(...)";
}

def HLSLSplitDouble: LangBuiltin<"HLSL_LANG"> {
let Spellings = ["__builtin_hlsl_elementwise_splitdouble"];
let Attributes = [NoThrow, Const];
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -7287,6 +7287,8 @@ def err_typecheck_illegal_increment_decrement : Error<
"cannot %select{decrement|increment}1 value of type %0">;
def err_typecheck_expect_int : Error<
"used type %0 where integer is required">;
def err_typecheck_expect_hlsl_resource : Error<
"used type %0 where __hlsl_resource_t is required">;
def err_typecheck_arithmetic_incomplete_or_sizeless_type : Error<
"arithmetic on a pointer to %select{an incomplete|sizeless}0 type %1">;
def err_typecheck_pointer_arith_function_type : Error<
Expand Down Expand Up @@ -12528,6 +12530,10 @@ def warn_attr_min_eq_max: Warning<

def err_hlsl_attribute_number_arguments_insufficient_shader_model: Error<
"attribute %0 with %1 arguments requires shader model %2 or greater">;
def err_hlsl_expect_arg_const_int_one_or_neg_one: Error<
"argument %0 must be constant integer 1 or -1">;
def err_invalid_hlsl_resource_type: Error<
"invalid __hlsl_resource_t type attributes">;

// Layout randomization diagnostics.
def err_non_designated_init_used : Error<
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19409,6 +19409,15 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef<Value *>{Op0},
nullptr, "hlsl.radians");
}
case Builtin::BI__builtin_hlsl_buffer_update_counter: {
Value *ResHandle = EmitScalarExpr(E->getArg(0));
Value *Offset = EmitScalarExpr(E->getArg(1));
Value *OffsetI8 = Builder.CreateIntCast(Offset, Int8Ty, true);
return Builder.CreateIntrinsic(
/*ReturnType=*/Offset->getType(),
CGM.getHLSLRuntime().getBufferUpdateCounterIntrinsic(),
ArrayRef<Value *>{ResHandle, OffsetI8}, nullptr);
}
case Builtin::BI__builtin_hlsl_elementwise_splitdouble: {

assert((E->getArg(0)->getType()->hasFloatingRepresentation() &&
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGHLSLRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class CGHLSLRuntime {
GENERATE_HLSL_INTRINSIC_FUNCTION(UClamp, uclamp)

GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromBinding, handle_fromBinding)
GENERATE_HLSL_INTRINSIC_FUNCTION(BufferUpdateCounter, bufferUpdateCounter)

//===----------------------------------------------------------------------===//
// End of reserved area for HLSL intrinsic getters.
Expand Down
Loading