Skip to content

Commit

Permalink
Add BINDLESS_READONLY and BINLDESS_WRITEONLY resource types
Browse files Browse the repository at this point in the history
New resource types allow to specify a read-only and write-only images.
  • Loading branch information
mmerecki authored and igcbot committed Dec 18, 2024
1 parent 95f5963 commit 0ea9c16
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
12 changes: 10 additions & 2 deletions IGC/Compiler/CISACodeGen/CheckInstrTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ void CheckInstrTypes::visitCallInst(CallInst& C)
g_InstrTypes.num1DAccesses++;
BufferType bufferType = DecodeBufferType(
CI->getArgOperand(0)->getType()->getPointerAddressSpace());
if (bufferType == UAV || bufferType == BINDLESS)
if (bufferType == UAV ||
bufferType == BINDLESS ||
bufferType == BINDLESS_READONLY)
{
g_InstrTypes.hasStorageBufferLoad = true;
}
Expand All @@ -380,7 +382,9 @@ void CheckInstrTypes::visitCallInst(CallInst& C)
g_InstrTypes.num1DAccesses++;
BufferType bufferType = DecodeBufferType(
CI->getArgOperand(0)->getType()->getPointerAddressSpace());
if (bufferType == UAV || bufferType == BINDLESS)
if (bufferType == UAV ||
bufferType == BINDLESS ||
bufferType == BINDLESS_WRITEONLY)
{
g_InstrTypes.hasStorageBufferStore = true;
}
Expand Down Expand Up @@ -564,6 +568,7 @@ void CheckInstrTypes::visitLoadInst(LoadInst& I)
g_InstrTypes.num1DAccesses++;
break;
case IGC::BINDLESS:
case IGC::BINDLESS_READONLY:
case IGC::SSH_BINDLESS:
g_InstrTypes.hasStorageBufferLoad = true;
break;
Expand All @@ -583,6 +588,7 @@ void CheckInstrTypes::visitLoadInst(LoadInst& I)
case IGC::CONSTANT_BUFFER:
case IGC::POINTER:
case IGC::BINDLESS_CONSTANT_BUFFER:
case IGC::BINDLESS_WRITEONLY:
case IGC::BINDLESS_TEXTURE:
case IGC::SAMPLER:
case IGC::BINDLESS_SAMPLER:
Expand Down Expand Up @@ -637,6 +643,7 @@ void CheckInstrTypes::visitStoreInst(StoreInst& I)
g_InstrTypes.num1DAccesses++;
break;
case IGC::BINDLESS:
case IGC::BINDLESS_WRITEONLY:
case IGC::SSH_BINDLESS:
g_InstrTypes.hasStorageBufferStore = true;
break;
Expand All @@ -656,6 +663,7 @@ void CheckInstrTypes::visitStoreInst(StoreInst& I)
case IGC::CONSTANT_BUFFER:
case IGC::POINTER:
case IGC::BINDLESS_CONSTANT_BUFFER:
case IGC::BINDLESS_READONLY:
case IGC::BINDLESS_TEXTURE:
case IGC::SAMPLER:
case IGC::BINDLESS_SAMPLER:
Expand Down
4 changes: 3 additions & 1 deletion IGC/Compiler/CISACodeGen/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,14 @@ namespace IGC

BufferAccessType getDefaultAccessType(BufferType bufTy)
{
static_assert(BufferType::BUFFER_TYPE_UNKNOWN == 17, "Please also update switch() below");
static_assert(BufferType::BUFFER_TYPE_UNKNOWN == 19, "Please also update switch() below");
switch (bufTy)
{
case BufferType::CONSTANT_BUFFER:
case BufferType::RESOURCE:
case BufferType::BINDLESS_TEXTURE:
case BufferType::BINDLESS_CONSTANT_BUFFER:
case BufferType::BINDLESS_READONLY:
case BufferType::STATELESS_READONLY:
case BufferType::SAMPLER:
case BufferType::BINDLESS_SAMPLER:
Expand All @@ -652,6 +653,7 @@ namespace IGC
case BufferType::STATELESS_A32:
return BufferAccessType::ACCESS_READWRITE;

case BufferType::BINDLESS_WRITEONLY:
case BufferType::RENDER_TARGET:
return BufferAccessType::ACCESS_WRITE;
default:
Expand Down
4 changes: 4 additions & 0 deletions IGC/Compiler/CISACodeGen/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ namespace IGC
{
return t == BINDLESS ||
t == BINDLESS_CONSTANT_BUFFER ||
t == BINDLESS_READONLY ||
t == BINDLESS_WRITEONLY ||
t == BINDLESS_TEXTURE;
}
inline bool IsSSHbindless(BufferType t)
Expand All @@ -261,6 +263,8 @@ namespace IGC
t == CONSTANT_BUFFER ||
t == BINDLESS ||
t == BINDLESS_CONSTANT_BUFFER ||
t == BINDLESS_READONLY ||
t == BINDLESS_WRITEONLY ||
t == SSH_BINDLESS ||
t == SSH_BINDLESS_CONSTANT_BUFFER;
}
Expand Down
2 changes: 2 additions & 0 deletions IGC/Compiler/CodeGenPublicEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ namespace IGC
SSH_BINDLESS,
SSH_BINDLESS_CONSTANT_BUFFER,
SSH_BINDLESS_TEXTURE,
BINDLESS_READONLY,
BINDLESS_WRITEONLY,
BUFFER_TYPE_UNKNOWN
};

Expand Down
17 changes: 11 additions & 6 deletions IGC/Compiler/Optimizer/SynchronizationObjectCoalescing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class SynchronizationObjectCoalescing : public llvm::FunctionPass
static bool IsFenceOperation(const llvm::Instruction* pInst);

////////////////////////////////////////////////////////////////////////
static bool IsGlobalResource(llvm::Type* pResourePointerType);
static bool IsGlobalWritableResource(llvm::Type* pResourePointerType);

////////////////////////////////////////////////////////////////////////
static bool IsSharedMemoryResource(llvm::Type* pResourePointerType);
Expand Down Expand Up @@ -1865,7 +1865,7 @@ IGC::InstructionMask SynchronizationObjectCoalescing::GetAtomicInstructionMaskFr
else
{
llvm::Type* pPointerType = pGenIntrinsicInst->getOperand(0)->getType();
if (IsGlobalResource(pPointerType))
if (IsGlobalWritableResource(pPointerType))
{
result = static_cast<InstructionMask>(result | InstructionMask::BufferReadOperation);
result = static_cast<InstructionMask>(result | InstructionMask::BufferWriteOperation);
Expand Down Expand Up @@ -2466,7 +2466,7 @@ bool SynchronizationObjectCoalescing::IsTypedReadOperation(const llvm::Instructi
switch (pGenIntrinsicInst->getIntrinsicID())
{
case llvm::GenISAIntrinsic::GenISA_typedread:
return true;
return IsGlobalWritableResource(pGenIntrinsicInst->getOperand(0)->getType());
default:
break;
}
Expand Down Expand Up @@ -2603,7 +2603,7 @@ bool SynchronizationObjectCoalescing::IsBufferReadOperation(const llvm::Instruct
{
if (llvm::Type* pPtrType = GetReadOperationPointerType(pInst))
{
return IsGlobalResource(pPtrType);
return IsGlobalWritableResource(pPtrType);
}
return false;
}
Expand All @@ -2613,7 +2613,7 @@ bool SynchronizationObjectCoalescing::IsBufferWriteOperation(const llvm::Instruc
{
if (llvm::Type* pPtrType = GetWriteOperationPointerType(pInst))
{
return IsGlobalResource(pPtrType);
return IsGlobalWritableResource(pPtrType);
}
return false;
}
Expand Down Expand Up @@ -2920,7 +2920,10 @@ bool SynchronizationObjectCoalescing::IsFenceOperation(const llvm::Instruction*
}

////////////////////////////////////////////////////////////////////////
bool SynchronizationObjectCoalescing::IsGlobalResource(llvm::Type* pResourePointerType)
/// Returns true for resources in the global memory (storage buffers or
/// storage images) that are not marked as ReadOnly in the shader.
bool SynchronizationObjectCoalescing::IsGlobalWritableResource(
llvm::Type* pResourePointerType)
{
uint as = pResourePointerType->getPointerAddressSpace();
switch (as)
Expand All @@ -2937,6 +2940,7 @@ bool SynchronizationObjectCoalescing::IsGlobalResource(llvm::Type* pResourePoint
{
case IGC::UAV:
case IGC::BINDLESS:
case IGC::BINDLESS_WRITEONLY:
case IGC::STATELESS:
case IGC::SSH_BINDLESS:
return true;
Expand All @@ -2946,6 +2950,7 @@ bool SynchronizationObjectCoalescing::IsGlobalResource(llvm::Type* pResourePoint
case IGC::POINTER:
case IGC::BINDLESS_CONSTANT_BUFFER:
case IGC::BINDLESS_TEXTURE:
case IGC::BINDLESS_READONLY:
case IGC::SAMPLER:
case IGC::BINDLESS_SAMPLER:
case IGC::RENDER_TARGET:
Expand Down

0 comments on commit 0ea9c16

Please sign in to comment.