Skip to content

Commit 9d40916

Browse files
MaciejKalinskisys_zuul
authored andcommitted
Minor refactoring.
Change-Id: Ia8e1a9dfb6eac87b70e4dae73bf70ae78ff040b3
1 parent 854ba05 commit 9d40916

File tree

7 files changed

+63
-53
lines changed

7 files changed

+63
-53
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ namespace IGC
269269
inline void Rsqrt(CVariable* dst, CVariable* src0);
270270
inline void Inv(CVariable* dst, CVariable* src0);
271271
inline void Not(CVariable* dst, CVariable* src0);
272+
// src0 * src1 + src2
272273
inline void Mad(CVariable* dst, CVariable* src0, CVariable* src1, CVariable* src2);
273274
inline void Lrp(CVariable* dst, CVariable* src0, CVariable* src1, CVariable* src2);
274275
inline void Xor(CVariable* dst, CVariable* src0, CVariable* src1);
@@ -777,6 +778,7 @@ namespace IGC
777778
DataMov(ISA_MOV, dst, src);
778779
}
779780

781+
// src0 * src1 + src2
780782
inline void CEncoder::Mad(CVariable* dst, CVariable* src0, CVariable* src1, CVariable* src2)
781783
{
782784
Arithmetic(ISA_MAD, dst, src0, src1, src2);

IGC/Compiler/CISACodeGen/CISACodeGen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace IGC
7474
EALIGN_AUTO
7575
};
7676

77-
static const unsigned int alignmentSize[] =
77+
static const std::array<unsigned int, 7> alignmentSize =
7878
{
7979
1,
8080
2,

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ void CShader::RestoreSP()
371371
void CShader::CreateImplicitArgs()
372372
{
373373
m_numBlocks = entry->size();
374-
m_R0 = GetNewVariable(getGRFSize() >> 2, ISA_TYPE_D, EALIGN_GRF, false, 1, CName::NONE);
374+
m_R0 = GetNewVariable(getGRFSize() / SIZE_DWORD, ISA_TYPE_D, EALIGN_GRF, false, 1, CName::NONE);
375375
encoder.GetVISAPredefinedVar(m_R0, PREDEFINED_R0);
376376

377377
// create variables for implicit args

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,7 +3402,8 @@ void EmitPass::emitOutput(llvm::GenIntrinsicInst* inst)
34023402
}
34033403
}
34043404

3405-
void EmitPass::emitPSInputMAD(llvm::Instruction* inst)
3405+
3406+
void EmitPass::emitPSInputMADHalf(llvm::Instruction* inst)
34063407
{
34073408
//create the payload and do interpolation
34083409
CPixelShader* psProgram = static_cast<CPixelShader*>(m_currShader);
@@ -3479,7 +3480,7 @@ void EmitPass::emitPSInput(llvm::Instruction* inst)
34793480
else if (inst->getType()->isHalfTy()
34803481
)
34813482
{
3482-
emitPSInputMAD(inst);
3483+
emitPSInputMADHalf(inst);
34833484
}
34843485
else
34853486
{

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ namespace IGC
346346
void emitPhaseInput(llvm::GenIntrinsicInst* inst);
347347

348348
void emitPSInput(llvm::Instruction* inst);
349-
void emitPSInputMAD(llvm::Instruction* inst);
349+
void emitPSInputMADHalf(llvm::Instruction* inst);
350350
void emitPSInputPln(llvm::Instruction* inst);
351351
void emitPSInputCst(llvm::Instruction* inst);
352352
void emitEvalAttribute(llvm::GenIntrinsicInst* inst);

IGC/Compiler/CISACodeGen/PixelShaderCodeGen.cpp

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ using namespace IGC::IGCMD;
4646

4747
namespace IGC
4848
{
49-
5049
CVariable* CPixelShader::GetR1()
5150
{
5251
return m_R1;
@@ -128,8 +127,10 @@ namespace IGC
128127

129128
void CPixelShader::AllocatePSPayload()
130129
{
130+
// In bytes
131131
uint offset = 0;
132-
//R0 is always allocated as a predefined variable. Increase offset for R0
132+
133+
// R0 is always allocated as a predefined variable. Increase offset for R0
133134
IGC_ASSERT(m_R0);
134135
offset += getGRFSize();
135136

@@ -192,11 +193,13 @@ namespace IGC
192193
offset += m_pPositionWPixel->GetSize();
193194
}
194195

195-
//Add support for POSITION_XY_OFFSET
196+
// Add support for POSITION_XY_OFFSET
196197
if (m_pPositionXYOffset)
197198
{
198-
AllocateInput(m_pPositionXYOffset, offset, i);
199-
offset += m_pPositionXYOffset->GetSize();
199+
{
200+
AllocateInput(m_pPositionXYOffset, offset, i);
201+
offset += m_pPositionXYOffset->GetSize();
202+
}
200203
}
201204

202205
// Add support for input coverage mask
@@ -206,42 +209,44 @@ namespace IGC
206209
offset += m_pInputCoverageMask->GetSize();
207210
}
208211

209-
if (m_pCPSRequestedSizeX || m_pCPSRequestedSizeY)
210-
{
211-
if (m_pCPSRequestedSizeX)
212-
{
213-
AllocateInput(m_pCPSRequestedSizeX, offset, i);
214-
}
215-
if (m_pCPSRequestedSizeY)
216-
{
217-
AllocateInput(m_pCPSRequestedSizeY, offset + SIZE_OWORD, i);
218-
}
219-
offset += getGRFSize();
220-
}
221-
if (m_ZWDelta)
222212
{
223-
AllocateInput(m_ZWDelta, offset, i);
224-
if (m_Signature)
225-
{
226-
GetDispatchSignature().ZWDelta = offset;
227-
}
228-
offset += getGRFSize();
229-
}
230-
if (m_SampleOffsetX || m_SampleOffsetY)
231-
{
232-
if (m_SampleOffsetX)
213+
if (m_pCPSRequestedSizeX || m_pCPSRequestedSizeY)
233214
{
234-
AllocateInput(m_SampleOffsetX, offset, i);
215+
if (m_pCPSRequestedSizeX)
216+
{
217+
AllocateInput(m_pCPSRequestedSizeX, offset, i);
218+
}
219+
if (m_pCPSRequestedSizeY)
220+
{
221+
AllocateInput(m_pCPSRequestedSizeY, offset + SIZE_OWORD, i);
222+
}
223+
offset += getGRFSize();
235224
}
236-
if (m_SampleOffsetY)
225+
if (m_ZWDelta)
237226
{
238-
AllocateInput(m_SampleOffsetY, offset + SIZE_OWORD, i);
227+
AllocateInput(m_ZWDelta, offset, i);
228+
if (m_Signature)
229+
{
230+
GetDispatchSignature().ZWDelta = offset;
231+
}
232+
offset += getGRFSize();
239233
}
240-
if (m_Signature)
234+
if (m_SampleOffsetX || m_SampleOffsetY)
241235
{
242-
GetDispatchSignature().pixelOffset = offset;
236+
if (m_SampleOffsetX)
237+
{
238+
AllocateInput(m_SampleOffsetX, offset, i);
239+
}
240+
if (m_SampleOffsetY)
241+
{
242+
AllocateInput(m_SampleOffsetY, offset + SIZE_OWORD, i);
243+
}
244+
if (m_Signature)
245+
{
246+
GetDispatchSignature().pixelOffset = offset;
247+
}
248+
offset += getGRFSize();
243249
}
244-
offset += getGRFSize();
245250
}
246251
}
247252

@@ -255,6 +260,7 @@ namespace IGC
255260

256261
IGC_ASSERT(offset % getGRFSize() == 0);
257262
unsigned int payloadEnd = offset;
263+
258264
//Allocate size for values coming from VS
259265
for (uint i = 0; i < setup.size(); i++)
260266
{
@@ -457,22 +463,22 @@ namespace IGC
457463
CVariable* inputVar = setup[index];
458464
if (inputVar == nullptr)
459465
{
460-
if (loweredInput)
466+
if (loweredInput)
467+
{
468+
if (index % 2 == 0)
461469
{
462-
if (index % 2 == 0)
463-
{
464-
inputVar = GetNewVariable(8, ISA_TYPE_F, EALIGN_GRF, true, CName::NONE);
465-
setup[index + 1] = GetNewAlias(inputVar, ISA_TYPE_F, 16, 4);
466-
}
467-
else
468-
{
469-
inputVar = GetNewAlias(GetInputDelta(index - 1), ISA_TYPE_F, 16, 4);
470-
}
470+
inputVar = GetNewVariable(8, ISA_TYPE_F, EALIGN_GRF, true, CName::NONE);
471+
setup[index + 1] = GetNewAlias(inputVar, ISA_TYPE_F, 16, 4);
471472
}
472473
else
473474
{
474-
inputVar = GetNewVariable(4, ISA_TYPE_F, EALIGN_OWORD, true, CName::NONE);
475+
inputVar = GetNewAlias(GetInputDelta(index - 1), ISA_TYPE_F, 16, 4);
475476
}
477+
}
478+
else
479+
{
480+
inputVar = GetNewVariable(4, ISA_TYPE_F, EALIGN_OWORD, true, CName::NONE);
481+
}
476482
setup[index] = inputVar;
477483
}
478484
return inputVar;
@@ -847,11 +853,11 @@ namespace IGC
847853
void CPixelShader::PreCompile()
848854
{
849855
CreateImplicitArgs();
850-
m_R1 = GetNewVariable(
851-
getGRFSize() / SIZE_DWORD, ISA_TYPE_D, EALIGN_HWORD, false,
852-
m_numberInstance, "R1");
853856
CodeGenContext* ctx = GetContext();
854857

858+
const uint8_t numberInstance = m_numberInstance;
859+
m_R1 = GetNewVariable(getGRFSize() / SIZE_DWORD, ISA_TYPE_D, EALIGN_GRF, false, numberInstance, "R1");
860+
855861
// make sure the return block is properly set
856862
if (ctx->getModule()->getNamedMetadata("KillPixel"))
857863
{

IGC/Compiler/CISACodeGen/ShaderCodeGen.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ namespace IGC
465465
bool GetHasGlobalAtomics() const { return m_HasGlobalAtomics; }
466466
calignmentSize as;
467467

468+
// In bytes
468469
uint32_t getGRFSize() const { return m_Platform->getGRFSize(); }
469470

470471

0 commit comments

Comments
 (0)