Граф коммитов

3150 Коммитов

Автор SHA1 Сообщение Дата
Jaebaek Seo aa4f5176eb
[spirv] do not set result type for OpImageWrite (#3757)
Based on the spec https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpImageWrite,
`OpImageWrite` does not have result type nor result id.
If we set the result type, the RelaxedPrecisionVisitor can set the `RelaxedPrecision` decoration for it.
It results in the invalid SPIR-V code.
2021-05-12 13:35:00 -04:00
Jaebaek Seo a8036844fa
[spirv] support image with minimum precision scalar data types (#3758)
For example, following textures have types with minimum precision scalar
as template parameters. We support minimum precision scalar types for
images.
```
RWTexture2D<min10float4> tex0;
RWTexture2D<min16uint4> tex1;
RWTexture2D<min12int4> tex2;
```
2021-05-12 10:51:37 -04:00
Vishal Sharma 742657ade4
Add option to override semantic defines (#3766) 2021-05-11 21:43:15 -07:00
Greg Roth 61bd18526d
Allow variable offsets to gathers (#3764)
Mostly reverts the change that added an error when offsets were not
immediate or out of range for gather operations. More research suggests
this error was not required and it broke some existing shaders

Fixes #3738
2021-05-11 17:04:58 -07:00
Tex Riddell 7df6e86405
Fix vec1 in vector conditional causing a bad cast in codegen (#3763) 2021-05-11 16:20:18 -07:00
Greg Roth f1edc82b21
Add InstCombine to Loop Delete followup passes (#3749)
Needed to pick up new DCE opportunities and fully eliminate useless
loops. We ran it after the total runs anyway. Now we run it after every
repetition

Correct a variable name typo

Add a test where loop deletion requires instruction simplification to
completely eliminate the loops without effect
2021-05-11 10:59:47 -07:00
Xiang Li 6f962b6f76
Add min limit for intrinsic stats. (#3761)
* Add min limit for intrinsic stats.
2021-05-10 15:40:36 -07:00
Xiang Li 7393664602
When AddOpcodeParamForIntrinsic, support intrinsic which returns a resource (#3762)
* When AddOpcodeParamForIntrinsic, support intrinsic which returns a resource.
2021-05-10 14:59:07 -07:00
Jeff Noyle ba1900c9da
PIX: Allow debug of enum classes (#3756)
Two things:
First recurse down type hierarchy. The previous code only went down 2 levels...
Second, derive base type from enum classes when populating fake debug-store locations
2021-05-07 20:07:41 -07:00
Xiang Li 2298848552
Skip structurize when only 1 ret. (#3754) 2021-05-06 22:39:31 -07:00
Xiang Li 254af3a55a
Don't widen type for hlsl in IndVarSimplify. (#3752) 2021-05-06 17:39:04 -07:00
Jaebaek Seo 6c57aeaff7
[spirv] always use r-value for flat conversion target (#3750)
The flat conversion method `SpirvEmitter::processFlatConversion()`
conducts bit-casts, composite construction, ... to covert the target to
the specific type. Since we cannot convert a pointer to other types, we
should make sure the target is r-value. In particular, it fixes bugs
when the target is a constant or texture buffer. The existing code just
returns `OpVariable` for the constant or texture buffer conversion, but
`OpVariable` is not r-value and it results in a spirv-val error.
2021-05-06 10:20:53 -04:00
Jaebaek Seo fd3694fc74
[spirv] fix use-after-free bug (#3748)
In high level, we did
```
llvm::StringRef choppedSrcCode;
{
  std::string text ...
  choppedSrcCode = text ...
}
// use choppedSrcCode
```

`choppedSrcCode` points a freed string.
2021-05-06 10:20:37 -04:00
Jaebaek Seo 3241aa8b68
[spirv] Make sure asuint() argument is r-value (#3747) 2021-05-06 10:10:29 -04:00
Jeff Noyle 320d40bf35
PIX: Change insertion point to after referenced value (#3746)
The value-to-declare pass replaces dbg.value with dbg.declare and some getElementPtr/store pairs that the PIX instrumentation uses to discover values. The problem here was that the dbg.value could reside in the program prior to the value it was referring to, and this seems to be legal. It's not correct once the dbg.value has been replaced with the GEP/store pairs, since the store was trying to operate on a value that had not yet been created. The solution is to move the builder's insertion point to that of the value itself, rather than that of the dbg.value.

Also in this change: a simple pair of copy-paste typos in the OffsetManager class.
2021-05-05 09:09:00 -07:00
Helena Kotas 56e22b30c5
Enable random order of hctbuild arguments (#3741) 2021-05-03 12:33:24 -07:00
Adam Yang b44890fe1e
Fixed linker not putting subprogram of inlined functions into CU (#3716) 2021-05-03 12:31:14 -07:00
Helena Kotas e621158fbf
Disable regeneration target for official builds as they always run a full clean build. (#3725)
This should eliminate the race-condition issue with "Cannot restore timestamp".
2021-04-29 19:13:30 -07:00
Jaebaek Seo 689ab7dc58
[spirv] Fix bug of CTBuffer DX memory layout with matrix (#3672)
When a CTBuffer contains a matrix and we use FXC memory layout for it i.e.,
`-fvk-use-dx-layout`, the memory layout of the generated struct is different
from what FXC generates. FXC memory layout rule for matrices or array of
matrices are:
1. `floatMxN` means `N` float vectors and each vector has `M` elements.
  - How to calculate size: 16 * (N - 1) + 4 * M bytes
  - How to calculate offset:
    - If the size is greater than or equal to 16 bytes: the offset must be aligned to 16 bytes
    - Otherwise (less than 16): it cannot be split into multiple 16 bytes slots.
  - For example, float2x3 has 16 * (3 - 1) + 4 * 2 = 40 bytes as its size. Since its size 40 bytes is greater than 16 bytes, it must be aligned to 16 bytes.

2. `floatMxN[K]` means an array of `floatMxN` with `K` elements.
  - size: (K - 1) * N * 16 + 16 * (N - 1) + 4 * M
  - offset:
    - If K > 1, it must be aligned to 16 bytes
    - If K == 1, it is the same with floatMxN.
  - For example, the size of float3x2 foo[7]; is (7 - 1) * 2 * 16 + 16 * (2 - 1) + 4 * 3 = 220.

The non-trivial case is `float1xN` which is a matrix with `N` vectors and each vector has 1 element.
Its size should be `16 * (N - 1) + 4` based on the FXC memory layout rule.
For example, the size of `float1x2` must be 20 in bytes, which means we want to put the first float value of
`float1x2` at the offset 0 in bytes and the second float value at the offset 16 in bytes.
It means we must not generate it as a SPIR-V vector type because setting it as a SPIR-V vector results in
putting the first at the offset 0 in bytes and the second at the offset 4 in bytes.
In addition, we cannot set it as a SPIR-V matrix type because SPIR-V does not allow a matrix with a single
row and a vector with a single element.
The only available option is to set it as a SPIR-V array with `ArrayStride 16`.

Since we currently consider `float1xN` as an `OpTypeVector` and generate all SPIR-V code based on the assumption.
Changing the type of `float1xN` to `OpTypeArray` needs huge engineering costs to handle all the cases.
For example, in many places e.g., addition, subtraction, multiplication, we use `OpVectorShuffle` for `float1xN` because we consider it as `OpTypeArray`.

Our solution is to create two variables for CTBuffer including `type1xN` with FXC memory layout:
1. Original: One with correct subtypes and memory layouts i.e., `OpTypeArray` for `type1xN`
2. Clone: One with Private storage class i.e., without physical memory layout
    - `OpTypeVector` for `type1xN` as the current DXC does.

The Original variable is in charge of getting CTBuffer data from CPU.
We create a module initialization function to copy the Original variable to the Clone variable.
We insert `OpFunctionCall` for the module initialization function into all entry points.
We use the Clone variable for the CTBuffer in all places.
2021-04-29 17:16:22 -04:00
Jaebaek Seo 3de85cffcc
[spirv] No temporary variable for local resource variable argument passing (#3721)
```
void getResource(out Texture2D<float4> result) {
  result = global_resource_variable;
}

void main() {
  Texture2D<float4> x;
  getResource(x);
  ...
}
```

SPIR-V backend currently creates a temporary variable to pass `x` as an
argument. In pseudo code:
```
temp_var = x
call getResource temp_var

// use x in main()
```

Since `getResource` will set `temp_var = global_resource_variable`,
we have to use `temp_var` for `x` in `main()`.
However, in `main()`, it always just uses `x`, not `temp_var`.
Therefore, setting `x` as `global_resource_variable` does not work.

This CL lets SPIR-V backend not create a temporary variable for the
local variable with a resource type for argument passing with `out` or
`inout` keyword.

Note that we preserve the behavior of a global variable with a resource type i.e., use a temporary variable. It is because we interpret a local variable or a function parameter with some resource types as a pointer to the resource type while we interpret a global variable with a resource type just as the resource not pointer.
For example, we interpret a local variable or a function parameter with `RWStructuredBuffer<float4>` type as `%_ptr_Function__ptr_StorageBuffer_type_RWStructuredBuffer_v4float` while a global variable with `RWStructuredBuffer<float4>` type as `%_ptr_StorageBuffer_type_RWStructuredBuffer_v4float`. Because of this difference, before we use a local variable or a function parameter with the type, we always dereference it exactly once more than a global variable. If we pass a function argument with `RWStructuredBuffer<float4>` type without a temporary parameter variable, we pass a global variable directly and conduct one more dereferencing that results in the incorrect SPIR-V for both syntax and semantics.
2021-04-29 16:41:28 -04:00
Vishal Sharma 5af55fadb9
Fix heap corruption due to dependency on StringRef (#3723) 2021-04-28 21:38:35 -07:00
Adam Yang 9a8816ba73
Added an pdb writer overload that doesn't take any input blobs (#3715) 2021-04-28 15:13:17 -07:00
Greg Roth 0e775ceb5e
Add sample code for error handling to testing (#3678)
Add the code presented in documentation to the build to ensure it
remains buildable.
2021-04-28 13:15:37 -07:00
Jaebaek Seo 2501f89613
[spirv] update SPIRV-Tools submodule (#3719) 2021-04-28 10:46:42 -04:00
Jaebaek Seo f66b04f584
[spirv] update SPIRV-Tools submodule (#3718) 2021-04-27 17:11:25 -04:00
Greg Roth 2d38a6a510
Add cases for new dxc exeptions (#3691)
These shouldn't ever really get hit, but there is a chance that the
exception is thrown inside a block that returns the hresult and discards
the exception with its message. We'd rather preserve the message, but as
a last resort, these messages are better than nothing
2021-04-27 06:25:58 -07:00
Greg Roth e1f594323b
Split gather offsets into separate test (#3712)
Gathers are more complicated and deserve more thorough testing in an
individual unit test
2021-04-27 06:22:40 -07:00
Tex Riddell 162a1587c6
Fix detection of inner UDT ptr used by lowered intrinsic (DispatchMesh) (#3713)
- In constant GEP case, the outer structure would be reported as used by
the intrinsic, preventing SROA of outer struct and resulting in the wrong
type for the intrinsic.
2021-04-26 17:25:50 -07:00
Helena Kotas 88ddd4c978
dxexp: add explicit dependency on D3D12 (#3710) 2021-04-26 14:49:31 -07:00
Greg Roth 56370bad8d
Correct iteration over users for gather offsets (#3709)
When converting the internal gatherimm intrinsic to the official dxil
variant after validation has been performed, user iteration went over
the edge, resulting in an app verifier problem. This corrects the
iteration.

Fixes #3674
2021-04-26 11:42:41 -07:00
Helena Kotas 7f44ae2e4c
Add -cmake-system-version argument to hctbuild.cmd to enable setting of target Windows version (min WinSDK version) (#3704) 2021-04-23 09:36:06 -07:00
Xiang Li bd38504d5e
Add -dumprs to dxa. (#3703) 2021-04-21 15:31:44 -07:00
Xiang Li e23eb7f89c
When exit_block is false block, use !exit_cond as exit_cond in RemoveUnstructedLoopExit. (#3701) 2021-04-21 12:52:15 -07:00
Jaebaek Seo 3be3d15fc6
[spirv] update SPIRV-Tools submodule (#3694) 2021-04-20 13:17:41 -04:00
Greg Roth d8ef429a0e
fix readme.md typo 2021-04-19 07:51:09 -07:00
Greg Roth bb625ac1e7
Update README.md with new appveyor information 2021-04-16 11:19:35 -07:00
Jaebaek Seo dd8db73da5
[spirv] update SPIRV-Tools and SPIRV-Headers (#3689) 2021-04-15 09:38:36 -04:00
Tex Riddell 098af75e48
Move ExecutionTest setup out of area shared with HLK code. (#3682) 2021-04-13 13:23:08 -07:00
Michael Haidl bbe33bcf11
DiagnosticsEngine incorrectly handles DiagnoceOnce diagnostics and asserts/crashes (#3683)
When a diagnostic that should be emitted with DiagnoceOnce has already been emitted, an invalid DiagnosticsBuilder is returned to prohibit another emittance of the diagnostic. The current implementation, however, does not set IsActive=false and the DiagnosticsEngine tries to emit a diagnostic with an invalid DiagID. This function is currently only used with payload access qualifiers to emit a warning only once if qualifiers are dropped because PAQs are disabled because of the SM version or the user opted-out. (Update the corresponding test accordingly).
2021-04-13 08:38:28 -07:00
Jaebaek Seo c9249f313c
[spirv] Use object of correct base class for method call (#3671)
When calling a method using an object, we have to correctly pass "this"
object. When the class of the object used for the method call has
multiple base classes, it does not use the correct base class. It simply
uses "this" object. This commit fixes the issue.

Fixes #3644
2021-04-12 13:37:13 -04:00
Junda Liu d31f05ffd6
[spirv] Add VK_KHR_variable_rate_fragment_shading SPIR-V support (#3664)
Change the mapping of SV_ShadingRate from FragSizeEXT (VK_EXT_fragment_density_map) to PrimitiveShadingRateKHR/ShadingRateKHR (VK_KHR_variable_rate_fragment_shading).
2021-04-12 10:06:49 -04:00
Xiang Li 6775e94ef1
Bump shader model to 6.7 (#3679) 2021-04-10 12:24:49 -07:00
David Peixotto 3960adab41
Parameterize the OP, OC, OCC values in the hctdb opcode table gen (#3673) 2021-04-07 21:36:14 -07:00
Xiang Li 5fa34d1fd6
Save root sig for entry for lib. (#3669)
* Save root sig for entry for lib.
2021-04-07 21:32:17 -07:00
Jaebaek Seo c879f2f9b5
[spirv] reply on spirv-val for variable offset for OpImage* validation (#3656)
spirv-val reports a validation error when we use variable offset for
OpImage*. We have to rely on spirv-val for the validation instead of
doing it in DXC. In particular, when the HLSL code uses the loop
invariant variable for the Sample() intrinsics, it should be a constant
value after conducting the loop unrolling. Since we rely on spirv-opt
for the loop unrolling, we should not report the validation error in
DXC.

Fixes #3575
2021-04-07 17:48:21 -04:00
Adam Yang 1f6d1facbf
Fixed a potential codegen difference with Zi (#3665) 2021-04-06 13:36:03 -07:00
Greg Roth f7a633ddad
Constrain convergent_cs mesh test threads (#3662)
Allows running on limited platforms
2021-04-05 10:51:48 -07:00
Jeff Noyle cb485263b7
PIX: Null check before dyn_cast (#3654)
dbg.value can occasionally return a null value. (Hit this in a customer (343) shader via PIX.) This is expected. From IntrinsicInst.cpp:

  // When the value goes to null, it gets replaced by an empty MDNode.
2021-04-01 17:39:02 -07:00
Helena Kotas d0b19d30b3
Fix crash on undeclared identifier inside a vector (#3653)
Fixes #3357
2021-04-01 17:35:18 -07:00
Greg Roth cac37e6890
No sinking coord calc for sample in libs (#3658)
Amidst catching the CS/AS/MS cases where convergent markers weren't
getting generated, it was pointed out that libs may need these too.
2021-04-01 15:40:34 -07:00