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

1564 Коммитов

Автор SHA1 Сообщение Дата
Lei Zhang 53576a601e
Turn modifier 'center' and friends into identifiers in more cases (#1423)
There are more cases in which the center/sample/etc modifier
should be treated as identifiers:

* Inside decoration groups
* In assignments
* Inside parentheses
* etc.

This commit adds a few more special handling cases that turns these
modifiers into identifiers, upon seeing the next token as punctuator.
2018-07-13 19:55:02 -04:00
Lei Zhang 01aad25f44
[spirv] Pull in vector shuffle fixes in SPIRV-Tools (#1424) 2018-07-13 19:09:11 -04:00
Tex Riddell 95c382de3f Merge branch 'master' into user/texr/integrate-master
# Conflicts:
#	lib/HLSL/DxilContainerReflection.cpp
#	tools/clang/tools/CMakeLists.txt
#	tools/clang/unittests/CMakeLists.txt
2018-07-13 15:01:10 -07:00
Lei Zhang d43410e0bc
Allow using modifier as field names for fxc compatibility (#1419) 2018-07-13 12:38:33 -04:00
Tex Riddell b4f0e37581 Merged PR 101: Store outputs before IgnoreHit/AcceptHitAndEndSearch
Store outputs before IgnoreHit/AcceptHitAndEndSearch

SROA_Parameter_HLSL would copy arguments to/from allocas at entry and each return.  These instrinsics need outputs to have been updated before the call, and do not return (have no-return attribute).

Make sure we copy to outputs before the function call by:
- Split block and add return immediately after call
- SROA_ParameterHLSL will then insert copy to outputs before each return
- In HLOperationLower, move call to just before the return (after copy to outputs)
- Later, the return (all code following the no-return call) will be replaced with 'unreachable'

Also fix build error in DxilPatchShaderRecordBindings.cpp with unused local var cast (void*)index;
2018-07-13 06:55:35 +00:00
Tex Riddell 734accbce5 Merged PR 100: Eliminate phi on resources/handles for library
Eliminate phi on resources/handles for library

- ensure all handles use only one global resource
- replace resource path with indices into global resource
- replace resource alloca with index allocas
- AddCreateHandleForPhiNodeAndSelect now unnecessary, deleted
- error on resources in library function params or return
- mark entry clones as internal linkage since they could contain params
  that are not allowed for libraries.
- fix MarkUavUpdateCounter - handle nested GEP
- disallow static resource use from exported library functions
- add/update tests
- detect undef resource paths that would otherwise be lost (FailUndefResource)
- set internal linkage for HL intrinsic function bodies so they aren't processed with user functions
- Rename legalize [static] resource use passes to DxilPromote(Local|Static)Resources
- Remove various dead code paths for resources, such as:
  GenerateParamDxilResourceHandles, RemoveLocalDxilResourceAllocas,
  lower handle cast, non-promotable error (may translate to index allocas)
- force resource GVs to external constant with no initializer
2018-07-13 02:04:31 +00:00
Xiang Li 3e24ab8ac1
Merge pull request #1422 from python3kgae/mat_fix
Fix crash when get matrix element on a function call.
2018-07-12 18:37:24 -07:00
Xiang Li 171fc86a7e Fix crash when get matrix element on a function call. 2018-07-12 17:30:05 -07:00
Lei Zhang 56ffc8a239
[spirv] Fix Vulkan layout struct member alignment error (#1418)
For VK_HKR_relaxed_block_layout, a vector inside structs can have
its offset as a multiple of its base element type's alignment.
But the vector's alignment is unaffected, esp. when used for
calculating the alignment of the whole enclosing struct.

Also enables SPIRV-Tools validation on block layouts.
2018-07-12 11:50:16 -04:00
Vishal Sharma 68c0437c71
Scalarize aggregates before loop unroll to enable mem2reg (#1417)
* Scalarize aggregates to enable mem2reg

* Accomodate CR comments
2018-07-11 17:03:27 -07:00
Greg Roth 7c4b5b21f6 Initialize all bits in IncludedFileIndexToHandle (#1414)
Included file HANDLEs are generated using the type, the file index
and some representation of the directory. Since they are not real
files on a real filesystem, they don't have genuine handles.
This conversion is performed using a union containing the above
values and a HANDLE object, which is returned after these are assigned
However, the size of the above values is far less than that of the
HANDLE, which leaves many bits uninitialized, containing random
values.

By initializing the handle to 0, then the capital-B "Bits" values,
no small-b bits are left uninitialized.
2018-07-11 18:20:29 -04:00
Greg Roth 0e0fe06189 [linux-port] Handle register number limits (#1412)
Like on other platforms, on Windows, strtoul is limited to the size
long. However, long on windows is 32, on linux, it's 64. So Linux
happily converts a string that requires more than 32 bits.
However, it is returned into a variable that is only 32 bits.

In order to keep Linux behavior consistent with Windows, and for
lack of a strtou function, strtoul is still called, but overflow
of 32 bits is detected and reported as an error, making Verifier-
Test happy.
2018-07-11 17:50:35 -04:00
Helena Kotas 36183ed715
Add 'center' keyword; allow 'sample', 'precise', 'center' and 'globallycoherent' as identifiers (#1406)
* Add 'center' keyword as an interpolation modifier

FXC allows the interpolation modifier 'center' (equivalent to 'linear') and DXC should too. At places where interpolation modifier is not expected 'center' can still be used as an identifier. This change makes it easier to switch from FXC to DXC. Add warnings when center is used with centroid or sample. Update varmod-syntax.hlsl test to include 'center'.

* Allow 'sample', 'precise' and 'globallycoherent' as identifiers

In DXC 'sample', 'precise' and 'globallycoherent' were treated as a keywords and could not be used as identifiers. FXC allowed this.
This change makes it easier to switch from FXC to DXC.

* Update fxc errors in varmods-syntax.hlsl based on fxc version 10.0.17713.
2018-07-11 14:46:31 -07:00
Greg Roth 051a7b639e [linux-port] Correct char convert size in/out (#1411)
MultiByteToWideChar and WideCharToMultiByte were returning -1 on
failure, which caused failures to be ignored. When successful, they
were returning the number of characters converted excluding the
terminating null character because that's what the std:: functions
used for the implementation do. Both are inconsistent with the
original Windows implementations.

Simply adding one to the return value works in all cases save those
where the number of characters converted was limited by the parameter
In this case, the number of characters converted doesn't include
the terminating null. So no addition is warrented.

Added addition errors in keeping with the function descriptions.

The CW2A conversion class left out the terminating null character
when calculating the max size of the converted string.
2018-07-10 16:57:21 -04:00
Greg Roth c34b6efa96 Fix lambda captures in dxilcontainer serializer (#1410)
A lambda function relied on captured variables after they went out
of scope. The result on Linux was access to random data. The effect
varies randomly just as returning a point to a variable that goes
out of scope might.
2018-07-10 16:40:18 -04:00
Greg Roth 68a3e86490 [linux-port] Add dxc -spirv test (#1409)
Due to existing bugs in debug builds, this couldn't be committed
before now. It should catch that and other issues by being tested
regularly. It just compiles a very simple HLSL shader to spirv and
compares with a previously generated spirv output file
2018-07-10 13:47:10 -04:00
Ehsan 367b193254
[linux-port] Enable Travis Linux and macOS bots. (#1407) 2018-07-09 11:30:27 -04:00
Lei Zhang a2dc672b9d
[spirv] Update SPIRV-Headers & SPIRV-Tools (#1404) 2018-07-05 15:28:32 -04:00
Ehsan 18545516b0
[spirv] Handle CalculateLevelOfDetailUnclamped. (#1400) 2018-07-04 15:55:21 -04:00
Lei Zhang 310c305150
[spirv] Support struct as Buffer/Texture template type (#1371)
fxc.exe supports templating Buffer/Texture with a struct type,
as long asthe struct type can be fit into a 4-component vector.
2018-07-04 14:06:38 -04:00
Lei Zhang ed29623d9a
[spirv] Handle nested structs for [[vk::offset]] (#1399)
Also update the SPIR-V doc about [[vk::offset]
2018-07-04 10:58:35 -04:00
Christopher Wallis 74520bb662 Merged PR 98: Adding a DxrFallbackCompiler.dll containing IDxcDxrFallbackCompiler implementation + tests
This adds an isolated component *IDxcDxrFallbackCompiler*  that is used by the D3D12 Raytracing Fallback Compiler. The component is responsible for linking together DXR shaders into a state machine capable of emulating function invocations including recursion, patching HLSL intrinsics, export renaming, and emulating Shader Record support. This component is compiled to a DxrFallbackCompiler.dll that gets consumedd with D3D12 Raytracing Fallback Compiler apps.

For deeper implementation details, I will be fleshing out lib\DxrFallback\readme.md

Some leftover work still required:

1. Currently the Fallback Layer tests compile to an exe that must be manually run. This should be refactored to conform with existing DXIL unittests.
2018-06-29 23:43:40 +00:00
Lei Zhang f13e38579d
[spirv] Pull in optimization fix for un-merging struct types (#1395) 2018-06-29 17:10:23 -04:00
Lei Zhang 3987db0fa8
[spirv] Do not build tests by default and hook up with ctest (#1394)
This way we can just run ctest to invoke the tests, instead of
remembering the binary and its parameters.
2018-06-29 12:46:07 -04:00
Ehsan 579b9c656f
[linux-port] Add documentation file for Linux/macOS port. (#1389) 2018-06-28 16:34:07 -04:00
Lei Zhang 15885f01ac
[spirv] Fix returning struct containing arrays (#1392)
We should always create a temporary variable for rvalues if we
are trying to get an access chain from it. Now do it in the
turnIntoElementPtr() function, which is used everywhere.

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1387
2018-06-28 16:31:57 -04:00
Ehsan d920192496
[linux-port] Set correct permissions on new files (#1388)
The previous implementation of CreateFileW for Unix didn't set any permission
flags for the new files it created. This sets the default file
permissions granting read and write permissions to the owner and
read permissions to everyone else. This perpetuates the behavior
before the offending change.

Also adds a few simple smoke tests to verify the code produced by
dxc as well as file creation behavior and other basic smoke-level
functionality of dxc.
2018-06-28 11:58:23 -04:00
Helena Kotas 43a0f6f88c Merged PR 99: Fix indexing of 16-bit-type vectors in CBuffer
Fix indexing of 16-bit-type vectors in CBuffer

Fixes #17967102
2018-06-28 08:04:35 +00:00
Lei Zhang f21c44400a
[spirv] Update SPIRV-Tools for not merging resource types (#1385)
Keeping the original struct type is important for some reflection
workflows.

The validation check for layout is alo included. But we disable
it for now and will re-enable it after fixing all the failures.

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1364
2018-06-27 20:54:38 -04:00
Helena Kotas 532365e99f Fix indexing of 16-bit-type vectors in CBuffer
Fixes #17967102
2018-06-27 13:53:02 -07:00
Ehsan e8d5eb0111
[linux-port] Enables the DXC main on Unix. (#1384) 2018-06-27 15:00:26 -04:00
Greg Roth eacaf5a58c [macos-port] Allow dxc and tests to run on mac (#1383)
The REGEX_H define prevented the inclusion of an Apple system header.
Not coincidentally, the same header regex_impl.h was derived from.

Prevent Apple warning by splitting macro args with an #else. Add HLSL
change comments too which were missing from the start.

Search for libdxcompiler.dylib instead of .so on Apple.

MacOS resolves symbols differently from Linux. Linux takes the first
valid resolution and then uses it wherever it is referenced. MacOS
more similar to Windows, favors symbols that are local to the
compilation unit.

This comes into play where functions set static globals such as
the malloc tls and the IMalloc contained there. The dxc binary
initializes these. For Linux, that's enough because all calls
resolve to the ones from this binary because they are encountered
first. MacOS calls that originate from within the dynamic library
resolve to the local functions, which don't have their globals
initialized. To initialize them, we need to do what is done in
DLLMain in DXCompiler.cpp.

Performing these calls results in duplicate initializations on Linux
unless the calls in question are given visibility hidden. This is
the default on Windows, but not on Unix OSes.
2018-06-27 13:42:23 -04:00
Lei Zhang eaff1735d0
[spirv] Emit error for atomics operations on floats (#1382) 2018-06-27 10:29:59 -04:00
Lei Zhang 0ff4329b04
[spirv] Emit better errors on unsupported resource type parameter (#1381) 2018-06-26 18:48:38 -04:00
Ehsan 9337fd2ef5
[linux-port] Enable cross-platform interfaces. (#1377)
As described #1342, this change makes it possible for interfaces to
compile on other platforms, without making any intrusive changes.
2018-06-26 17:45:21 -04:00
Greg Roth 3670c1372d [linux-port] Use cross-platform dynamic lib load (#1380)
LLVM includes a DynamicLibrary class that works on multiple platforms
Rather than ifdefing between dlopen for non-Windows and LoadLibraryW
on Windows, using this class allows us to abstract platform differences
while using the same code.

Changed DxilLibInitialize to attempt to initialize dxil.dll so the
smart mutex inside the dynamic library object uses the same IMalloc
as the other ManagedStatic objects so they can all be freed in order.
2018-06-26 17:33:14 -04:00
Greg Roth 4aa0ac6c50 [linux-port] Fix GCC build on alpine Linux (and others) (#1378)
Alpine Linux and probably several others, define fopen64, fseeko64,
ftello64, and tmpfile64 to their 32 bit equivalents in system
headers. This results in duplicates in areas of the code that
include 32 bit and 64 bit references to this. Since HLSL doesn't
have any of these functions anyway, we can safely exclude them.
2018-06-26 15:15:32 -04:00
Ehsan f8f0bfcf0b
[linux-port] FileSystem and IO. (#1374)
Some interactions with the FileSystem are not used by any API and are
therefore not implemented for Unix at the moment. We have put assertions in
place to make it easy to spot if any of those methods are ever used.
2018-06-26 15:05:08 -04:00
Ehsan 01e5e240fa
[linux-port] Final update to cmake files for cross-platform compilation. (#1376)
This change disables the build targets that are not supported on Unix
platforms when compiling on those platforms.

We were also ignoring DXCompiler.cpp when compilation in the past. We
can now bring it back.

We have also added cmake-predefined-config-params which contains all the
cmake configurations needed to build on Unix platforms. It will make it
easy for developers to build.
2018-06-26 14:32:55 -04:00
Ehsan 29a058b75c
[linux-port] Add missing header include or class declaration. (#1375) 2018-06-26 14:23:28 -04:00
Lei Zhang ad55bca496
[spirv] Avoid writing unused stage output variable back (#1373)
Some workflow relies on trimming off unused stage output variables.
But we created a wrapper around the source code entry function to
satisfy Vulkan's requirement over entry function signature.
Previously we just blindly write back all stage output variables
in the wrapper function no matter whether the corresponding stage
output variable is used or not in the source code entry function.
Now we can be a little bit clever based on the usedness info
from the AST.
2018-06-26 12:45:11 -04:00
Tex Riddell 5dfdd9bca3 Merged PR 97: Remove phi on resources, follow phi and select on handles in validation 2018-06-26 00:58:28 +00:00
Ehsan 4799c6ce50
[linux-port] Enable some code. Disable some code. (#1372)
Some code originally in llvm/clang was commented out, and was replaced
with Windows-specific implementation. In this change we bring back some
of those.

Also disabled some code that is not relevant any more.

And a few minor improvements towards cross-platform compilation.
2018-06-25 20:15:54 -04:00
Ehsan 285490211f
[linux-port] Complete the Windows adapter code. (#1358)
This change completes the necessary adapter code needed to enable
cross-platform compilation.

Discussion on the design/implementation of these are in issue #1341 and
isuee #1342.

In addition to the adapter classes/structs, there exists usages of
Windows-specific functions in the codebase. In some cases, we won't need
to compile/run some of those methods on non-Windows platforms. For the
few cases where we do, we have implemented equivalent functionality in
WindowsFunctions.cpp.
2018-06-25 16:04:13 -04:00
Greg Roth 29a2f05ffd [linux-port] Cross-platform critical section (#1339)
InitializeCriticalSection, DeleteCriticalSection, EnterCriticalSection,
and LeaveCriticalSection serve to create a mutual exclusion section of
code, but they are stubbed out currently for non-win platforms.

There is multi-platform support for the same functionality in LLVM
in the form of SmartMutex. This switches from the Windows specific
to the abstraction, allowing the same code to work on other platforms.
2018-06-23 21:44:14 -04:00
Ehsan f7cd091e93
[linux-port] Add MultiByte<->WideChar methods. (#1357) 2018-06-23 21:43:39 -04:00
Tex Riddell 6663dac50f Merge branch 'master' into user/texr/integrate-master
# Conflicts:
#	lib/HLSL/DxilContainerAssembler.cpp
#	lib/HLSL/DxilGenerationPass.cpp
#	lib/HLSL/DxilLinker.cpp
#	lib/HLSL/DxilModule.cpp
#	lib/HLSL/DxilOperations.cpp
#	lib/HLSL/DxilTypeSystem.cpp
#	lib/HLSL/DxilValidation.cpp
#	lib/HLSL/HLMatrixLowerPass.cpp
#	lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp
2018-06-22 12:05:49 -07:00
Lei Zhang 82c289db99
[spirv] Avoid unifying struct types with different names (#1367)
We were unifying struct types as long as they have the exact
same members (regardless of names). BUt it turns out some
reflection workflow requires the exact original struct type
to work.
2018-06-22 08:20:17 -04:00
Greg Roth cbe8b9ce78 Correct min21_int typo in ItaniumMangle (#1369)
Determines what the type is represented as in function name mangling.
Just as easy to get it right. Simple typo fix.

Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/1368
2018-06-22 07:31:11 -04:00
Tex Riddell e9d8bd9831 Merged PR 96: Add shader mask and min SM to RDAT
Add shader mask and min SM to RDAT
- add OP::GetMinShaderModelAndMask to compute mask and min SM
- account for ops that can be translated during linking
- update PS ops that could be allowed in library functions
- update min SM with newer optional feature flags

Fix AV in TranslateHLSubscript for typed buffer with struct element
2018-06-22 00:31:08 +00:00