Skip to content

Commit df62355

Browse files
mmereckigfxbot
authored andcommitted
In all stages this method returns its argument. In the past this method was used to add URB header size to the global offset. Now codegens for all stages correctly calculate the URB offset
Change-Id: I903256dbd3a8897d65719b99df273cc33b6833a0
1 parent 435db02 commit df62355

10 files changed

+49
-75
lines changed

IGC/Compiler/CISACodeGen/DomainShaderCodeGen.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,13 @@ CVariable* CDomainShader::GetURBInputHandle(CVariable* pVertexIndex)
174174
encoder.SetSimdSize(SIMDMode::SIMD8);
175175
encoder.SetSrcRegion(0, 1, 4, 0);
176176
encoder.SetSrcSubReg(0, 0);
177-
177+
178178
encoder.Copy(m_pURBReadHandleReg, GetR0());
179179
encoder.Push();
180180
}
181181
return m_pURBReadHandleReg;
182182
}
183183

184-
QuadEltUnit CDomainShader::GetFinalGlobalOffet(QuadEltUnit globalOffset)
185-
{
186-
return globalOffset;
187-
}
188-
189184
uint32_t CDomainShader::GetMaxInputSignatureCount()
190185
{
191186
return m_pMaxInputSignatureCount;
@@ -198,7 +193,7 @@ void CDomainShader::AllocatePayload()
198193
//R0 is always allocated as a predefined variable. Increase offset for R0
199194
assert(m_R0);
200195
offset += getGRFSize();
201-
196+
202197
if(m_ShaderDispatchMode == ShaderDispatchMode::DUAL_PATCH)
203198
{
204199
if (!m_Platform->DSPrimitiveIDPayloadPhaseCanBeSkipped() || m_hasPrimitiveIdInput)
@@ -212,7 +207,7 @@ void CDomainShader::AllocatePayload()
212207
offset += getGRFSize();
213208

214209
AllocateInput(GetSymbol(m_properties.m_VArg), offset);
215-
offset += getGRFSize();
210+
offset += getGRFSize();
216211

217212
AllocateInput(GetSymbol(m_properties.m_WArg), offset);
218213
offset += getGRFSize();
@@ -279,7 +274,7 @@ void CDomainShader::FillProgram(SDomainShaderKernelProgram* pKernelProgram)
279274
pKernelProgram->VertexURBEntryOutputLength = GetURBAllocationSize() - GetURBHeaderSize();
280275
pKernelProgram->VertexURBEntryReadLength = GetVertexURBEntryReadLength();
281276
pKernelProgram->VertexURBEntryReadOffset = OctEltUnit(0);
282-
pKernelProgram->VertexURBEntryOutputReadOffset = GetURBHeaderSize();
277+
pKernelProgram->VertexURBEntryOutputReadOffset = GetURBHeaderSize();
283278
pKernelProgram->ConstantBufferLoaded = m_constantBufferLoaded;
284279
pKernelProgram->DeclaresRTAIndex = m_properties.m_isRTAIndexDeclared;
285280
pKernelProgram->DeclaresVPAIndex = m_properties.m_isVPAIndexDeclared;
@@ -292,7 +287,7 @@ void CDomainShader::FillProgram(SDomainShaderKernelProgram* pKernelProgram)
292287

293288
void CDomainShader::AddEpilogue(llvm::ReturnInst* pRet)
294289
{
295-
if(this->GetContext()->platform.WaForceDSToWriteURB() &&
290+
if(this->GetContext()->platform.WaForceDSToWriteURB() &&
296291
m_ShaderDispatchMode != ShaderDispatchMode::DUAL_PATCH)
297292
{
298293
CVariable* channelMask = ImmToVariable(0xFF, ISA_TYPE_D);

IGC/Compiler/CISACodeGen/DomainShaderCodeGen.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CDomainShader : public CShader
4747
void AllocatePayload();
4848
void ExtractGlobalVariables();
4949
void SetShaderSpecificHelper(EmitPass* emitPass);
50-
50+
5151
// Return the domain point variables
5252
llvm::Argument* GetDomainPointUArgu();
5353
llvm::Argument* GetDomainPointVArgu();
@@ -63,9 +63,8 @@ class CDomainShader : public CShader
6363

6464
virtual CVariable* GetURBInputHandle(CVariable* pVertexIndex);
6565
virtual CVariable* GetURBOutputHandle();
66-
virtual QuadEltUnit GetFinalGlobalOffet(QuadEltUnit globalOffset);
6766
uint32_t GetMaxInputSignatureCount();
68-
67+
6968
virtual void AddEpilogue(llvm::ReturnInst* ret);
7069
CVariable* GetPrimitiveID();
7170

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5891,7 +5891,7 @@ void EmitPass::emitURBRead(llvm::GenIntrinsicInst* inst)
58915891
false,
58925892
pPerSlotOffset != nullptr,
58935893
false,
5894-
m_currShader->GetFinalGlobalOffet(globalOffset).Count(),
5894+
globalOffset.Count(),
58955895
EU_GEN8_URB_OPCODE_SIMD8_READ);
58965896

58975897
uint exDesc = EU_MESSAGE_TARGET_URB;

IGC/Compiler/CISACodeGen/GeometryShaderCodeGen.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ uint CGeometryShader::GetInputPrimitiveVertexCount(USC::GSHADER_INPUT_PRIMITIVE_
147147
case USC::GSHADER_INPUT_PATCHLIST_30 : return 30;
148148
case USC::GSHADER_INPUT_PATCHLIST_31 : return 31;
149149
case USC::GSHADER_INPUT_PATCHLIST_32 : return 32;
150-
150+
151151
default:
152152
assert(0 && "Input primitive type not implemented");
153153
return 0;
@@ -233,7 +233,7 @@ CVariable* CGeometryShader::GetURBInputHandle(CVariable* pVertexIndex)
233233
{
234234
encoder.SetSrcSubVar(0, vertexIndex);
235235
}
236-
236+
237237
encoder.Copy(pSelectedHandles, GetURBReadHandlesReg());
238238
encoder.Push();
239239
}
@@ -245,7 +245,7 @@ CVariable* CGeometryShader::GetURBInputHandle(CVariable* pVertexIndex)
245245
{
246246
encoder.SetSrcRegion(0, 16, 8, 2);
247247
}
248-
248+
249249
if(!m_properties.Input().HasInstancing())
250250
{
251251
// offset = vertexIndex * 32 since offset needs to be in bytes, not grf numbers
@@ -269,27 +269,22 @@ CVariable* CGeometryShader::GetURBInputHandle(CVariable* pVertexIndex)
269269
CVariable* URBHandles = GetURBReadHandlesReg();
270270
pSelectedHandles = GetNewAddressVariable(
271271
pOffset->IsUniform() ? 1 : numLanes(m_SIMDSize),
272-
ISA_TYPE_UD,
273-
pOffset->IsUniform(),
272+
ISA_TYPE_UD,
273+
pOffset->IsUniform(),
274274
URBHandles->IsUniform());
275275
encoder.AddrAdd(pSelectedHandles, URBHandles, pOffset);
276276
encoder.Push();
277277
}
278278
return pSelectedHandles;
279279
}
280280

281-
QuadEltUnit CGeometryShader::GetFinalGlobalOffet(QuadEltUnit globalOffset)
282-
{
283-
return globalOffset;
284-
}
285-
286281
void CGeometryShader::AllocatePayload()
287282
{
288283
uint offset = 0;
289284

290285
// Allocate 8 DWORDS for the global URB Header which stores the cut bits.
291286
// The global header is 16 DWORDS which is a max of 512 bits.
292-
// So a GS can max output 1024 DWORDS/ 3 channels = 341 vertices
287+
// So a GS can max output 1024 DWORDS/ 3 channels = 341 vertices
293288
// (1024 max dwords so assuming no attributes).
294289

295290
// R0 & R1 are always allocated.
@@ -327,7 +322,7 @@ void CGeometryShader::AllocatePayload()
327322

328323
assert(offset % getGRFSize() == 0);
329324

330-
// when instancing mode is on, there is only one set of inputs and it's
325+
// when instancing mode is on, there is only one set of inputs and it's
331326
// laid out like in constant buffers, i.e. one attribute takes four subregisters
332327
// of one GRF register.
333328
const uint varSize = m_properties.Input().HasInstancing() ? SIZE_DWORD : getGRFSize();
@@ -363,38 +358,38 @@ void CGeometryShader::FillProgram(SGeometryShaderKernelProgram* pKernelProgram)
363358
// Gen 7 specific Compiler Output
364359
pKernelProgram->OutputTopology = m_properties.Output().TopologyType();
365360
pKernelProgram->SamplerCount = m_properties.SamplerCount();
366-
361+
367362
pKernelProgram->OutputVertexSize = GetOutputVertexSize();
368363
pKernelProgram->VertexEntryReadLength = GetVertexEntryReadLength();
369364

370365
TODO("Fix compiler output structures for uninitialized fields");
371-
pKernelProgram->IncludeVertexHandles = (m_pURBReadHandlesReg!=nullptr); // Used for PULL model.
366+
pKernelProgram->IncludeVertexHandles = (m_pURBReadHandlesReg!=nullptr); // Used for PULL model.
372367
pKernelProgram->VertexEntryReadOffset = OctEltUnit(0); // Include also vertex header, so start from the beginning.
373368

374369
pKernelProgram->ControlDataHeaderFormat = m_properties.Output().ControlDataFormat();
375370
pKernelProgram->GSEnable = true;
376371

377-
// Default StreamID is also dependent on the GSEnable but since we set it to true here we are
372+
// Default StreamID is also dependent on the GSEnable but since we set it to true here we are
378373
// not considering it right now.
379374
auto defStreamID = m_properties.Output().DefaultStreamID();
380375
pKernelProgram->DefaultStreamID = (defStreamID != -1 ? defStreamID : 0);
381376

382377
pKernelProgram->ControlDataHeaderSize = m_properties.Output().ControlDataHeaderSize();
383-
378+
384379
// Since we support only channel serial, the only mode for GS is SIMD8.
385380
pKernelProgram->DispatchMode = USC::GFX3DSTATE_GEOMETRY_SHADER_DISPATCH_MODE_SIMD8;
386-
381+
387382
pKernelProgram->IncludePrimitiveIDEnable = (m_pPrimitiveID != nullptr);
388383
auto instanceCount = m_properties.Input().InstanceCount();
389384
pKernelProgram->InstanceCount = (instanceCount == 0) ? 1 : instanceCount;
390385
pKernelProgram->ReorderEnable = true;
391386
pKernelProgram->DiscardAdjacencyEnable = CGeometryShader::DiscardAdjacency(m_properties.Input().InputPrimitiveType());
392387
pKernelProgram->SBEVertexURBEntryReadOffset = pKernelProgram->VertexEntryReadOffset;
393-
388+
394389
pKernelProgram->URBAllocationSize = GetURBAllocationSize();
395390

396391
pKernelProgram->UserClipDistancesMask = m_properties.Output().PerVertex().ClipDistanceMask();
397-
pKernelProgram->UserCullDistancesMask = m_properties.Output().PerVertex().CullDistanceMask();
392+
pKernelProgram->UserCullDistancesMask = m_properties.Output().PerVertex().CullDistanceMask();
398393

399394
pKernelProgram->MaxOutputVertexCount = m_properties.Output().MaxVertexCount();
400395

@@ -407,9 +402,9 @@ void CGeometryShader::FillProgram(SGeometryShaderKernelProgram* pKernelProgram)
407402
TODO("Max threads should be calculated based on the registers spilled. -> This needs to change")
408403
pKernelProgram->ExpectedVertexCount = m_properties.Input().VertexCount();
409404
pKernelProgram->StaticOutput = !m_properties.Output().HasNonstaticVertexCount();
410-
411-
pKernelProgram->StaticOutputVertexCount =
412-
(m_properties.Output().HasNonstaticVertexCount()) ?
405+
406+
pKernelProgram->StaticOutputVertexCount =
407+
(m_properties.Output().HasNonstaticVertexCount()) ?
413408
0 : m_properties.Output().ActualStaticVertexCount();
414409

415410
pKernelProgram->GSVertexURBEntryOutputReadOffset = GetVertexURBEntryOutputReadOffset();
@@ -481,7 +476,7 @@ Unit<Element> CGeometryShader::GetLocalOffset(SGVUsage usage)
481476
URBAllocationUnit CGeometryShader::GetURBAllocationSize() const
482477
{
483478
// Calculate the size of all vertices to be emitted, rounded up to 32B.
484-
auto vertexCount = m_properties.Output().HasNonstaticVertexCount()?
479+
auto vertexCount = m_properties.Output().HasNonstaticVertexCount()?
485480
m_properties.Output().MaxVertexCount() : m_properties.Output().ActualStaticVertexCount();
486481

487482
const OctEltUnit vertexSpace = round_up<OctElement>(
@@ -498,7 +493,7 @@ URBAllocationUnit CGeometryShader::GetURBAllocationSize() const
498493
}
499494

500495
/// Returns the size of the output vertex.
501-
/// Unit: 16B = 4 DWORDs
496+
/// Unit: 16B = 4 DWORDs
502497
/// Note: Each output vertex must be 32B-aligned when rendering is enabled (Ref. GS URB Entry).
503498
/// Therefore, the output vertex size is also rounded up to a multiple of 2.
504499
QuadEltUnit CGeometryShader::GetOutputVertexSize() const
@@ -514,7 +509,7 @@ OctEltUnit CGeometryShader::GetInputVertexHeaderSize() const
514509

515510
OctEltUnit CGeometryShader::GetVertexEntryReadLength() const
516511
{
517-
// if we use pull model, we don't use payload data and use URB read handles
512+
// if we use pull model, we don't use payload data and use URB read handles
518513
// in that case Vertex Entry Read Length should be zero.
519514
// If we don't use URB read handles, we cannot have read length zero (even if we don't read
520515
// anything from inputs) because of hardware restriction.

IGC/Compiler/CISACodeGen/GeometryShaderCodeGen.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CGeometryShader : public CShader
5555

5656
/// Fills in the kernel program structure with data determined during compilation.
5757
void FillProgram(SGeometryShaderKernelProgram* pKernelProgram);
58-
58+
5959
/// Returns a V-ISA variable that gets initialized to input PrimitiveID payload values.
6060
CVariable* GetPrimitiveID();
6161

@@ -76,17 +76,14 @@ class CGeometryShader : public CShader
7676
/// Add an epilogue which could check if we are terminating with a URB write or not.
7777
void AddEpilogue(llvm::ReturnInst* ret) override;
7878

79-
/// Adjusts the urb read offset by the size of the vertex header. Identity function in GS since
80-
/// we already set offsets adjusted by header size.
81-
virtual QuadEltUnit GetFinalGlobalOffet(QuadEltUnit globalOffset) override;
8279
private:
8380
/// False if we expect to see also vertices adjacent to the input as part of the input.
8481
/// field 3DSTATE_GS::DiscardAdjacency.
8582
static bool DiscardAdjacency(USC::GSHADER_INPUT_PRIMITIVE_TYPE inpPrimType);
8683

8784
/// Returns the index of a channel where the data with given SGV usage is placed.
8885
static Unit<Element> GetLocalOffset(SGVUsage usage);
89-
86+
9087
/// Returns the GS URB allocation size.
9188
/// This is the size of GS URB entry consisting of the header data and all vertex URB entries.
9289
/// Unit: 64B = 16 DWORDs
@@ -113,18 +110,18 @@ class CGeometryShader : public CShader
113110
/// This value is used to set the corresponding field in 3DSTATE_GS.
114111
OctEltUnit GetVertexURBEntryOutputReadLength() const;
115112

116-
/// Returns the offset that SBE should use when reading the URB entries
117-
/// output by Geometry shader.
113+
/// Returns the offset that SBE should use when reading the URB entries
114+
/// output by Geometry shader.
118115
/// This value is used to set the corresponding field in 3DSTATE_GS.
119116
/// Unit: 32B = 8DWORDS.
120117
OctEltUnit GetVertexURBEntryOutputReadOffset() const;
121118

122-
/// Returns a(newly allocated if not already present) variable that keeps input vertex
119+
/// Returns a(newly allocated if not already present) variable that keeps input vertex
123120
/// URB handles used for pull model data reads.
124121
CVariable* GetURBReadHandlesReg();
125122

126123
//********** Input State data
127-
124+
128125
/// Stores an array of vertex URB Read handles that are used for pull model data reads.
129126
CVariable* m_pURBReadHandlesReg;
130127

@@ -135,7 +132,7 @@ class CGeometryShader : public CShader
135132

136133
/// This variable holds the URB handle for the output vertices.
137134
CVariable* m_pURBWriteHandleReg;
138-
135+
139136
/// Holds v-isa variable that keeps PrimitiveID value for each primitive.
140137
CVariable* m_pPrimitiveID;
141138

IGC/Compiler/CISACodeGen/HullShaderCodeGen.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,6 @@ CVariable* CHullShader::GetURBInputHandle(CVariable* pVertexIndex)
362362
}
363363
}
364364

365-
QuadEltUnit CHullShader::GetFinalGlobalOffet(QuadEltUnit globalOffset)
366-
{
367-
return globalOffset;
368-
}
369-
370365
uint32_t CHullShader::GetMaxNumOfPushedInputs() const
371366
{
372367
uint numberOfPatches = (m_properties.m_pShaderDispatchMode == EIGHT_PATCH_DISPATCH_MODE) ? 8 : 1;

IGC/Compiler/CISACodeGen/HullShaderCodeGen.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class CHullShader : public CShader
5454
CVariable* GetR1();
5555
CVariable* GetR2();
5656
virtual CVariable* GetURBInputHandle(CVariable* pVertexIndex);
57-
virtual QuadEltUnit GetFinalGlobalOffet(QuadEltUnit globalOffset);
5857
virtual uint32_t GetMaxNumOfPushedInputs() const;
5958

6059
void EmitPatchConstantHeader(

IGC/Compiler/CISACodeGen/ShaderCodeGen.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class CShader
105105
assert(!"Should be overridden in a derived class!");
106106
return nullptr;
107107
}
108-
virtual QuadEltUnit GetFinalGlobalOffet(QuadEltUnit globalOffset) { return QuadEltUnit(0); }
109108
virtual bool hasReadWriteImage(llvm::Function &F) { return false; }
110109
virtual bool CompileSIMDSize(SIMDMode simdMode, EmitPass &EP, llvm::Function &F) { return true; }
111110
CVariable* LazyCreateCCTupleBackingVariable(

0 commit comments

Comments
 (0)