Skip to content

Commit 0ea9c16

Browse files
mmereckiigcbot
authored andcommitted
Add BINDLESS_READONLY and BINLDESS_WRITEONLY resource types
New resource types allow to specify a read-only and write-only images.
1 parent 95f5963 commit 0ea9c16

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

IGC/Compiler/CISACodeGen/CheckInstrTypes.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ void CheckInstrTypes::visitCallInst(CallInst& C)
368368
g_InstrTypes.num1DAccesses++;
369369
BufferType bufferType = DecodeBufferType(
370370
CI->getArgOperand(0)->getType()->getPointerAddressSpace());
371-
if (bufferType == UAV || bufferType == BINDLESS)
371+
if (bufferType == UAV ||
372+
bufferType == BINDLESS ||
373+
bufferType == BINDLESS_READONLY)
372374
{
373375
g_InstrTypes.hasStorageBufferLoad = true;
374376
}
@@ -380,7 +382,9 @@ void CheckInstrTypes::visitCallInst(CallInst& C)
380382
g_InstrTypes.num1DAccesses++;
381383
BufferType bufferType = DecodeBufferType(
382384
CI->getArgOperand(0)->getType()->getPointerAddressSpace());
383-
if (bufferType == UAV || bufferType == BINDLESS)
385+
if (bufferType == UAV ||
386+
bufferType == BINDLESS ||
387+
bufferType == BINDLESS_WRITEONLY)
384388
{
385389
g_InstrTypes.hasStorageBufferStore = true;
386390
}
@@ -564,6 +568,7 @@ void CheckInstrTypes::visitLoadInst(LoadInst& I)
564568
g_InstrTypes.num1DAccesses++;
565569
break;
566570
case IGC::BINDLESS:
571+
case IGC::BINDLESS_READONLY:
567572
case IGC::SSH_BINDLESS:
568573
g_InstrTypes.hasStorageBufferLoad = true;
569574
break;
@@ -583,6 +588,7 @@ void CheckInstrTypes::visitLoadInst(LoadInst& I)
583588
case IGC::CONSTANT_BUFFER:
584589
case IGC::POINTER:
585590
case IGC::BINDLESS_CONSTANT_BUFFER:
591+
case IGC::BINDLESS_WRITEONLY:
586592
case IGC::BINDLESS_TEXTURE:
587593
case IGC::SAMPLER:
588594
case IGC::BINDLESS_SAMPLER:
@@ -637,6 +643,7 @@ void CheckInstrTypes::visitStoreInst(StoreInst& I)
637643
g_InstrTypes.num1DAccesses++;
638644
break;
639645
case IGC::BINDLESS:
646+
case IGC::BINDLESS_WRITEONLY:
640647
case IGC::SSH_BINDLESS:
641648
g_InstrTypes.hasStorageBufferStore = true;
642649
break;
@@ -656,6 +663,7 @@ void CheckInstrTypes::visitStoreInst(StoreInst& I)
656663
case IGC::CONSTANT_BUFFER:
657664
case IGC::POINTER:
658665
case IGC::BINDLESS_CONSTANT_BUFFER:
666+
case IGC::BINDLESS_READONLY:
659667
case IGC::BINDLESS_TEXTURE:
660668
case IGC::SAMPLER:
661669
case IGC::BINDLESS_SAMPLER:

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,14 @@ namespace IGC
629629

630630
BufferAccessType getDefaultAccessType(BufferType bufTy)
631631
{
632-
static_assert(BufferType::BUFFER_TYPE_UNKNOWN == 17, "Please also update switch() below");
632+
static_assert(BufferType::BUFFER_TYPE_UNKNOWN == 19, "Please also update switch() below");
633633
switch (bufTy)
634634
{
635635
case BufferType::CONSTANT_BUFFER:
636636
case BufferType::RESOURCE:
637637
case BufferType::BINDLESS_TEXTURE:
638638
case BufferType::BINDLESS_CONSTANT_BUFFER:
639+
case BufferType::BINDLESS_READONLY:
639640
case BufferType::STATELESS_READONLY:
640641
case BufferType::SAMPLER:
641642
case BufferType::BINDLESS_SAMPLER:
@@ -652,6 +653,7 @@ namespace IGC
652653
case BufferType::STATELESS_A32:
653654
return BufferAccessType::ACCESS_READWRITE;
654655

656+
case BufferType::BINDLESS_WRITEONLY:
655657
case BufferType::RENDER_TARGET:
656658
return BufferAccessType::ACCESS_WRITE;
657659
default:

IGC/Compiler/CISACodeGen/helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ namespace IGC
235235
{
236236
return t == BINDLESS ||
237237
t == BINDLESS_CONSTANT_BUFFER ||
238+
t == BINDLESS_READONLY ||
239+
t == BINDLESS_WRITEONLY ||
238240
t == BINDLESS_TEXTURE;
239241
}
240242
inline bool IsSSHbindless(BufferType t)
@@ -261,6 +263,8 @@ namespace IGC
261263
t == CONSTANT_BUFFER ||
262264
t == BINDLESS ||
263265
t == BINDLESS_CONSTANT_BUFFER ||
266+
t == BINDLESS_READONLY ||
267+
t == BINDLESS_WRITEONLY ||
264268
t == SSH_BINDLESS ||
265269
t == SSH_BINDLESS_CONSTANT_BUFFER;
266270
}

IGC/Compiler/CodeGenPublicEnums.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ namespace IGC
9696
SSH_BINDLESS,
9797
SSH_BINDLESS_CONSTANT_BUFFER,
9898
SSH_BINDLESS_TEXTURE,
99+
BINDLESS_READONLY,
100+
BINDLESS_WRITEONLY,
99101
BUFFER_TYPE_UNKNOWN
100102
};
101103

IGC/Compiler/Optimizer/SynchronizationObjectCoalescing.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class SynchronizationObjectCoalescing : public llvm::FunctionPass
485485
static bool IsFenceOperation(const llvm::Instruction* pInst);
486486

487487
////////////////////////////////////////////////////////////////////////
488-
static bool IsGlobalResource(llvm::Type* pResourePointerType);
488+
static bool IsGlobalWritableResource(llvm::Type* pResourePointerType);
489489

490490
////////////////////////////////////////////////////////////////////////
491491
static bool IsSharedMemoryResource(llvm::Type* pResourePointerType);
@@ -1865,7 +1865,7 @@ IGC::InstructionMask SynchronizationObjectCoalescing::GetAtomicInstructionMaskFr
18651865
else
18661866
{
18671867
llvm::Type* pPointerType = pGenIntrinsicInst->getOperand(0)->getType();
1868-
if (IsGlobalResource(pPointerType))
1868+
if (IsGlobalWritableResource(pPointerType))
18691869
{
18701870
result = static_cast<InstructionMask>(result | InstructionMask::BufferReadOperation);
18711871
result = static_cast<InstructionMask>(result | InstructionMask::BufferWriteOperation);
@@ -2466,7 +2466,7 @@ bool SynchronizationObjectCoalescing::IsTypedReadOperation(const llvm::Instructi
24662466
switch (pGenIntrinsicInst->getIntrinsicID())
24672467
{
24682468
case llvm::GenISAIntrinsic::GenISA_typedread:
2469-
return true;
2469+
return IsGlobalWritableResource(pGenIntrinsicInst->getOperand(0)->getType());
24702470
default:
24712471
break;
24722472
}
@@ -2603,7 +2603,7 @@ bool SynchronizationObjectCoalescing::IsBufferReadOperation(const llvm::Instruct
26032603
{
26042604
if (llvm::Type* pPtrType = GetReadOperationPointerType(pInst))
26052605
{
2606-
return IsGlobalResource(pPtrType);
2606+
return IsGlobalWritableResource(pPtrType);
26072607
}
26082608
return false;
26092609
}
@@ -2613,7 +2613,7 @@ bool SynchronizationObjectCoalescing::IsBufferWriteOperation(const llvm::Instruc
26132613
{
26142614
if (llvm::Type* pPtrType = GetWriteOperationPointerType(pInst))
26152615
{
2616-
return IsGlobalResource(pPtrType);
2616+
return IsGlobalWritableResource(pPtrType);
26172617
}
26182618
return false;
26192619
}
@@ -2920,7 +2920,10 @@ bool SynchronizationObjectCoalescing::IsFenceOperation(const llvm::Instruction*
29202920
}
29212921

29222922
////////////////////////////////////////////////////////////////////////
2923-
bool SynchronizationObjectCoalescing::IsGlobalResource(llvm::Type* pResourePointerType)
2923+
/// Returns true for resources in the global memory (storage buffers or
2924+
/// storage images) that are not marked as ReadOnly in the shader.
2925+
bool SynchronizationObjectCoalescing::IsGlobalWritableResource(
2926+
llvm::Type* pResourePointerType)
29242927
{
29252928
uint as = pResourePointerType->getPointerAddressSpace();
29262929
switch (as)
@@ -2937,6 +2940,7 @@ bool SynchronizationObjectCoalescing::IsGlobalResource(llvm::Type* pResourePoint
29372940
{
29382941
case IGC::UAV:
29392942
case IGC::BINDLESS:
2943+
case IGC::BINDLESS_WRITEONLY:
29402944
case IGC::STATELESS:
29412945
case IGC::SSH_BINDLESS:
29422946
return true;
@@ -2946,6 +2950,7 @@ bool SynchronizationObjectCoalescing::IsGlobalResource(llvm::Type* pResourePoint
29462950
case IGC::POINTER:
29472951
case IGC::BINDLESS_CONSTANT_BUFFER:
29482952
case IGC::BINDLESS_TEXTURE:
2953+
case IGC::BINDLESS_READONLY:
29492954
case IGC::SAMPLER:
29502955
case IGC::BINDLESS_SAMPLER:
29512956
case IGC::RENDER_TARGET:

0 commit comments

Comments
 (0)