Sampler opaque ptr readiness

This change is part of the effort to support opaque pointers in next
llvm versions.
This commit is contained in:
Ossowski, Jacek
2025-10-23 16:07:56 +00:00
committed by igcbot
parent ecf98ed502
commit 945b3f6733
3 changed files with 14 additions and 35 deletions

View File

@ -81,7 +81,10 @@ void FixResourcePtr::RemoveGetBufferPtr(GenIntrinsicInst *bufPtr, Value *bufIdx)
uint outAS = bufPtr->getType()->getPointerAddressSpace();
uint origAS = outAS;
BufferType bufType = (BufferType)(cast<ConstantInt>(bufPtr->getOperand(1))->getZExtValue());
uint encodeAS = EncodeAS4GFXResource(*bufIdx, bufType);
// address space contains texture dimension information
// it has to be saved for further use
auto resourceDimType = DecodeAS4GFXResourceType(outAS);
uint encodeAS = EncodeAS4GFXResource(*bufIdx, bufType, 0, false, resourceDimType);
if (outAS != encodeAS && (bufType == CONSTANT_BUFFER || bufType == RESOURCE || bufType == UAV)) {
// happens to OGL, need to fix if address-space encoding is wrong
outAS = encodeAS;

View File

@ -26,6 +26,7 @@ SPDX-License-Identifier: MIT
#include "skuwa/iacm_g10_rev_id.h"
#include "skuwa/iacm_g11_rev_id.h"
#include "skuwa/iacm_g12_rev_id.h"
#include "IGC/common/ResourceAddrSpace.h"
namespace llvm {
class GenIntrinsicInst;
@ -172,7 +173,8 @@ public:
LLVM3DBuilder(const LLVM3DBuilder &) = delete;
LLVM3DBuilder &operator=(const LLVM3DBuilder &) = delete;
static unsigned EncodeASForGFXResource(const llvm::Value &bufIdx, IGC::BufferType bufType, unsigned uniqueIndAS);
static unsigned EncodeASForGFXResource(const llvm::Value &bufIdx, IGC::BufferType bufType, unsigned uniqueIndAS,
IGC::ResourceDimType resourceDimTypeId = std::nullopt);
llvm::Value *CreateFAbs(llvm::Value *V);
llvm::Value *CreateFSat(llvm::Value *V);

View File

@ -20,16 +20,7 @@ SPDX-License-Identifier: MIT
#include "common/LLVMWarningsPop.hpp"
#include "Probe/Assertion.h"
#include "visa/include/visa_igc_common_header.h"
typedef union _gfxResourceAddressSpace {
struct _bits {
unsigned int bufId : 16;
unsigned int bufType : 5;
unsigned int indirect : 1; // bool
unsigned int reserved : 10;
} bits;
unsigned int u32Val;
} GFXResourceAddressSpace;
#include "IGC/common/ResourceAddrSpace.h"
enum class ADDRESS_SPACE_TYPE : unsigned int {
ADDRESS_SPACE_PRIVATE = 0,
@ -42,29 +33,12 @@ enum class ADDRESS_SPACE_TYPE : unsigned int {
template <typename T, typename Inserter>
unsigned LLVM3DBuilder<T, Inserter>::EncodeASForGFXResource(const llvm::Value &bufIdx,
IGC::BufferType bufType,
unsigned uniqueIndAS) {
GFXResourceAddressSpace temp = {};
static_assert(sizeof(temp) == 4, "Code below may need and update.");
temp.u32Val = 0;
IGC_ASSERT((bufType + 1) < IGC::BUFFER_TYPE_UNKNOWN + 1);
temp.bits.bufType = bufType + 1;
if (bufType == IGC::BufferType::SLM) {
return static_cast<unsigned int>(
ADDRESS_SPACE_TYPE::ADDRESS_SPACE_LOCAL); // OCL uses addrspace 3 for SLM. We should use the same thing.
} else if (llvm::isa<llvm::ConstantInt>(&bufIdx)) {
const unsigned bufId = (unsigned)(llvm::cast<llvm::ConstantInt>(&bufIdx)->getZExtValue());
IGC_ASSERT(bufId < (1 << 16));
temp.bits.bufId = bufId;
return temp.u32Val;
}
// if it is indirect-buf, it is front-end's job to give a proper(unique) address-space per access
temp.bits.bufId = uniqueIndAS;
temp.bits.indirect = 1;
return temp.u32Val;
IGC::BufferType bufType,
unsigned uniqueIndAS,
IGC::ResourceDimType resourceDimTypeId) {
return IGC::EncodeAS4GFXResource(
bufIdx, bufType, uniqueIndAS, false,
resourceDimTypeId.value_or(IGC::RESOURCE_DIMENSION_TYPE::NUM_RESOURCE_DIMENSION_TYPES));
}
template <typename T, typename Inserter>