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

2149 Коммитов

Автор SHA1 Сообщение Дата
Tristan Labelle 28f0fe4701
Crashes and precise test updates (#2081)
Adds crash tests for bugs #2077, and #2061.
Removes crash test for closed bug #1882.
Adds a bunch of tests for "precise" attribute, whose effects I just learned about. Lead to filing bugs #2078, #2079 and #2080 due to divergences in behavior with FXC.
2019-04-30 10:50:43 -07:00
Tristan Labelle 6264641b94
Preserve snorm/unorm on resource template args (#2107)
This is a partial solution to preserving snorm and unorm for Buffer and other resource types. In the clang type system, the canonical type of Buffer<snorm float> is a RecordType for the template specialization, which is Buffer<float>, so the information is lost. However, the type of the variable itself has a sugar node of type TemplateSpecializationType which provides the exact type arguments that were provided to the template class to select its specialization. Hence we can retrieve the information if we have access to the VarDecl's type.

This is a partial solution, because the snorm/unorm is still not encoded in the canonical type of the variable, which means that it is still legal to assign resources that differ between their use of the attribute. However, it should unblock the use of the feature with backends that consume this metadata.
2019-04-30 10:49:49 -07:00
Tristan Labelle 725189cf17
Remove malloc usages in favor of operator new (#2150)
In a few places, llvm uses malloc instead of operator new, especially with collections that want to avoid calling constructors. In those cases, the allocation won't go through our custom allocator and will crash rather than throw on out-of-memory conditions. This fixes the biggest offenders.
2019-04-30 10:26:36 -07:00
Ehsan 8270b9f795
[spirv] Emit Float16 capability if float16 type is used. (#2147) 2019-04-30 10:35:49 -04:00
Tex Riddell e97d1b1c77
Merge pull request #2143 from tex3d/dxc-opts3
Add -Qembed_debug, don't embed debug info by default
2019-04-24 21:20:36 -07:00
Tex Riddell 753d02595c Merge remote-tracking branch 'ms/master' into dxc-opts3
# Conflicts:
#	lib/DxilContainer/DxilContainerAssembler.cpp
2019-04-24 20:20:36 -07:00
Tex Riddell 47d2600312 Emit warning for auto-embed behavior and update tests 2019-04-24 17:45:58 -07:00
Tristan Labelle b5f9280fa2
Remove shell api dependency. (#2141)
StringCompareOrdinal lives in kernel32.dll, better than previous implementations which pulled functions from user32.dll or shlwapi.dll.
2019-04-24 14:22:36 -07:00
Xiang Li 58b3d23cfc
Support Qstrip_reflect. (#2139)
* Support Qstrip_reflect.
2019-04-24 12:58:25 -07:00
Adam Yang cfb330ef56
Fixed bug where allocas get inserted at the wrong place. (#2140) 2019-04-23 11:32:54 -07:00
Tristan Labelle 93035fd2a5
Fix allocator mismatch with CompileWithDebug output string (#2137)
We declare CHeapPtr<wchar_t> DebugBlobName;, where CHeapPtr uses the CCRTAllocator by default, but initialize it with: Unicode::UTF8BufferToUTF16ComHeap(pDebugName, &DebugBlobName), which uses CComHeapPtr<wchar_t> p;

If we don't hit any exceptions, things are fine because we end up doing: *ppDebugBlobName = DebugBlobName.Detach(); , so the destructor will be a no-op.
2019-04-23 08:07:49 -07:00
Adam Yang 91f37618db
Turn stores to initializer for static variable where possible. (#2122) 2019-04-22 08:59:06 -07:00
Tex Riddell 69882a0394 Add -Qembed_debug, don't embed debug info by default
- New -Qembed_debug is required to embed PDB in shader container
- -Zi used without -Qembed_debug will not embed debug info anymore,
  and will issue a warning from CompileWithDebug().
- When compiling with Compile() and -Zi, -Qembed_debug is assumed
  for compatibility reasons (lots of breaks without it)
- In dxc and CompileWithDebug() -Fd implies -Qstrip_debug
- Debug name is based on -Fd, unless path ends with '\', meaning you
  want auto-naming and file written under the specified directory
- Debug name always embedded when debug info used, or -Fd used
- -Fd without -Zi just embeds debug name for CompileWithDebug(),
  still error with dxc, since it can't write to your file.
- If not embedding debug info, it doesn't get written to the container,
  only to be stripped out again.
- Fix padding for alignment in DebugName part.
- Default to DebugNameForBinary instead of DebugNameForSource if no
  DebugInfo enabled

- Also fixed missing dependency on table gen options from libclang
2019-04-19 19:57:25 -07:00
Helena Kotas 850c8d3676
Fix empty struct check (#2134)
Fixes llvm assert and debug-only test failure (CodeGenHLSL\batch\misc\emptyStruct.hlsl).
2019-04-19 14:38:10 -07:00
Jeff Noyle 4c0075162b
Optimize SlotTracker usage, remove printing of disasm (not needed) and add an instruction count report 2019-04-19 13:40:27 -07:00
John Porto 45acc2f87e
replaces StrCmpW/StrCmpIW with CComBSRT::operator != (#2133) 2019-04-19 12:36:12 -07:00
Tristan Labelle d56f6eb93f
Fix allocator issues for dxc blob allocations (#2130)
DxcCreateBlobOnHeapCopy allocated using the COM allocator and freed using the default thread allocator, leading to crashes.

But more generally, some DxcCreateBlob functions would take ownership of the passed-in buffer without also having the caller explicitly specify what IMalloc to use for deallocation, which is an error-prone pattern, so I reworked these methods a bit.

This also lead me to find some memory leaks and general memory mismanagement in the the rewriter.
2019-04-18 15:04:06 -07:00
Tristan Labelle 9ce4942f1c
Remove padding in empty structs (#2124)
Clang implicitly adds an i8 to empty structs. Subsequent empty struct fields in a larger structure get packed differently by clang (all in one dword) than by the llvm DataLayout (one per dword), causing inconsistent debug metadata. With this change, we stop adding implicit i8s, such that empty structs are zero-sized and we don't have to ignore their dummy field, which fixes debug info inconsistencies.
2019-04-17 16:29:35 -07:00
Jaebaek Seo 8d86efebe4
[spirv] fix Interlocked member call type cast bug (#2121) 2019-04-15 13:11:20 -04:00
Tex Riddell fcc51926b3
Fix CB Var Size reported by reflection (#2125)
Used to report next member minus this offset, which would include cb
padding in the size.  This is not correct.

Now we calculate the size based on the packing rules for the type.
- basic types are:
  (((elements * rows) - 1) * row stride) + cols * element size
  where row stride is 16, or 32 if 64-bit and cols > 2.
- for struct:
  struct size = offset of last field + size of last field
  struct size += (elements - 1) * 16-byte aligned struct size

Turned on Size check in reflection tests since it should be correct now.
2019-04-13 17:10:51 -07:00
Jaebaek Seo 5b0d61aa05
[spirv] fix no-op matrix type cast bug (#2111)
Type cast float2x2 to int2x2 causes a validation error when emitting
SPIR-V. This CL fixes it by adding type conversion in InitListHandler.
2019-04-11 12:23:07 -04:00
Ehsan c73ee4f202
[spirv] Support for #pragma pack_matrix(). (#2112)
The front-end has taken care of annotating the AST nodes with
the right attribute on QualTypes. We need to read that information
properly and use it in the SPIR-V backend.
2019-04-11 11:34:34 -04:00
Ehsan 8b501a9af3
[spirv] Fix wrong test file name. (#2118)
The real test file was never running :(
2019-04-11 10:07:03 -04:00
Tex Riddell faacd80b74
Allow clip/cull elements to be declared as array [2] (#2109)
* Allow clip/cull elements to be declared as array [2]

- This approach fixes validation and packing to handle this case.
- There could be implications to runtime ViewID validation
- fix some issues found in packing related to rowsUsed result from Pack
  functions.  Make these return 0 on failure, instead of startRow.
- Split PackNext into FindNext and PackNext that uses it for greater
  flexibility.
2019-04-10 17:37:47 -07:00
Tristan Labelle cb51784fe2
Revert lying about resource sizes in debug info. (#2114)
Pull request #2086 lies about the size of resources to ensure that backends can always expect 32 bits in the debug info. However, this causes warnings/errors in code containing structs of a resource type and a numerical type, because SROA uses the LLVM size rather than the clang size, and those are expected to be in sync. So the dwarf is going to say that the resource is 32 bits, but LLVM will think it is 64 bits (given our current definition of the struct).
2019-04-10 14:58:18 -07:00
Ehsan 428296a22d
[spirv] Support MatrixToVector cast for 2x2 matrices. (#2113) 2019-04-10 13:42:51 -04:00
Ehsan 09a9497ca8
[spirv] Update SPIRV-Tools (get storage class opt fix). (#2116) 2019-04-10 11:35:52 -04:00
Tristan Labelle 4167dd46f2
Fix nondeterminism around patch constant functions (#2099)
When multiple hull shaders point to a single patch constant buffer, we would iterate over the hull shaders, during which we would apply a transformation on the patch constant buffer and erase it. This means that subsequent hull shaders will be pointing to an already-deleted patch constant buffer. If the pointer got reused by a new function, we got into weird situations were we would remove a newer function while trying to clean an invalidated pointer.

The solution is to bin hull shaders by their common patch constant function. Transform the patch constant function without deleting the original, performing the replace on every using hull shader function, and only then deleting the original function.
2019-04-09 14:19:50 -07:00
Adam Yang 345b8b5743
Fixed a bug where nested LCSSA creation uses wrong body for outer loops. (#2105) 2019-04-05 11:39:12 -07:00
Tristan Labelle bd40fbf52c
Fixed a null DIExpression which survived in the matrix return case. (#2101) 2019-04-04 12:42:44 -07:00
Tristan Labelle ada42260b2
Fix an assert on cbuffer loads of bool vectors. (#2104)
After loading a vector from a cbuffer, we attempt moving the debug info upstream, to the individually loaded elements, assuming that they got converted into a vector by a sequence of insertelement instructions. This is not the case for bool vectors, because the insertelement sequence will be followed by a mem-to-reg conversion. Made the code more resilient to such unexpected patterns (better to lose debug info than to crash compilation).
2019-04-04 11:44:33 -07:00
Adam Yang 75df1b1436
Correct size for empty struct element in debug info. (#2103) 2019-04-04 11:04:22 -07:00
Ehsan 2da31a2187
[spirv] Update SPIRV-Tools and SPIRV-Headers. (#2102) 2019-04-03 17:35:03 -04:00
Ehsan c0890437df
[spirv] Use proper signedness in LowerTypeVisitor for LitInt. (#2100) 2019-04-03 17:34:51 -04:00
Ehsan Nasiri e0098e8f68 [spirv] Use SetVector for storing Capabilities. 2019-04-03 17:33:54 -04:00
Ehsan Nasiri 259853a75a [spirv] Use SetVector for storing Decorations. 2019-04-03 17:33:54 -04:00
Ehsan Nasiri 156d7facde [spirv] Use SetVector for storing Extensions.
If we use SetVector, we don't need to do a linear search of existing
extensions to figure out whether an extension has already been used or
not.
2019-04-03 17:33:54 -04:00
Ehsan Nasiri 687a05a227 [spirv] Removed unused headers. 2019-04-03 17:33:54 -04:00
Tristan Labelle 55b29a12c4
Improve matrix and constant buffer debug info. (#2076)
- Hijack dwarf debug info to present matrices as having _11 to _44 fields, similar to vectors
- Better preservation of debug info for constant buffer loads
- Improve and rename resource loading tests
- Improve and reorganize vector members tests, adding matrix members test
2019-04-03 11:49:03 -07:00
Tristan Labelle 103501d5f7
No more ir sensitive compilertest (#2093)
Tests should not depend on SSA value naming/numbering. A bit of regex magic and those two last tests can now be moved to quick-test.
2019-04-03 09:01:46 -07:00
Tristan Labelle d37ae5fc88
Improve debug type information for resources. (#2086)
- Hide the resource members in the debug information as they are internal implementation details.
- Force the size of resources to be reported as 32 bits (sizeof(intptr)). It's not useful for resources to have a size based on the internal fields we stick in there, it's more useful for backends to be able to expect a fixed resource size, even though what they end up generating might be bigger.
2019-04-03 08:38:27 -07:00
Tristan Labelle 7fe34820a8
Add tests for debug info of half and double types (16 and 64-bit). (#2091) 2019-04-03 08:37:11 -07:00
Tristan Labelle 61a7876742
Make the array out of bounds error conditional on the HLSL version. (#2096) 2019-04-02 14:55:16 -07:00
Tristan Labelle c4e9191dd0
Fix compiler crash on using incomplete type. (#2073)
Using a forward declared type without a definition may well be illegal, but it shouldn't crash the compiler.
2019-04-02 14:52:59 -07:00
Tristan Labelle da39de13ab
Move almost all batch-run CodeGenHLSL tests to a batch subdirectory. (#2092)
One more small step in reorganizing the CodeGenHLSL tests. Most batch-run tests are moved under CodeGenHLSL\batch such that there is only one TAEF test referencing this root folder, and we can freely move and reorganize files within there without risking to break any code.

Note that:

- I left the quick-test directory (now empty except for a single placeholder test), in case other people have pull requests which add tests there. This is just a staging measure against build breaks.
- I didn't move the debug subfolder because I have a number of pull requests modifying its contents
- I couldn't move "Samples" because some tests reach into it to run specific files, in addition to the whole thing being batch run

No test were changed, only files moved. CompilerTest.cpp was updated to remove the old batch-run directories in favor of a single test for batch-running the "batch" subfolder.
2019-04-02 14:18:29 -07:00
Tristan Labelle ecfa00c8e3 Make the array out of bounds error conditional on the HLSL version. 2019-04-02 09:31:51 -07:00
Ehsan 0010f0d348
[spirv] Use QualType in constant instruction constructors (#2088)
* [spirv] Use QualType in SpirvConstantBoolean constructor.

We switched constant instruction constructors to use QualType, but had
forgotten about SpirvConstantBoolean. This makes things consistent.

* [spirv] Only use QualType for creating SpirvConstantNull.
2019-04-02 10:56:23 -04:00
Ehsan 456d770192
[spirv] Simplify the logic in InitListHandler::decompose. (#2090) 2019-04-02 10:55:19 -04:00
Tristan Labelle 41ef8bd2c8
Remove DXIL Dia's assert which makes assumptions about dwarf bit pieces. (#2094)
In the general case, bit_pieces might be only for part of a register or register range. For example a half in a VGPR or a SGPRx4 for which we only have debug info for the first register.
2019-04-01 15:43:22 -07:00
Tristan Labelle cc42781591
Fixed implicit conversions between arrays and structs
FXC considers arrays the same as structures for implicit conversions, so int[2] should be implicitly convertible to struct { int x; float y; }, for example.
2019-04-01 12:33:21 -07:00