[PATCH] D136913: [HLSL] support RWByteAddressBuffer.

Xiang Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 21:01:04 PDT 2022


python3kgae created this revision.
python3kgae added reviewers: pow2clk, beanz, bogner.
Herald added a subscriber: Anastasia.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Only RWByteAddressBuffer::Load is supported in this PR.
Implement Load by cast handle to uint8_t ptr first.
Then add the byte address to get target address.
Cast the target address to target type ptr and deref.

struct RWByteAddressBuffer {

  void *handle;
  template<typename T> Load(uint i) {
     return *((T*)(((uint8_t*)handle) + i));
  }

};

Allow ref/ptr use for HLSLExternalSemaSource to skip the check when Location is invalid.

Also add HLSLResourceHelper to share code for RWByteAddressBuffer and RWBuffer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136913

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/AST/HLSL/RWByteAddressBuffer.hlsl
  clang/test/SemaHLSL/BuiltIns/RWByteAddressBuffer.hlsl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136913.471391.patch
Type: text/x-patch
Size: 24465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221028/ab8ed0e6/attachment-0001.bin>


More information about the cfe-commits mailing list