summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
Commit message (Collapse)AuthorAgeFilesLines
* spirv/i965/anv: Relax push constant offset assertions being 32-bit alignedJose Maria Casanova Crespo2018-02-281-2/+0
| | | | | | | | | | | | | | | | The introduction of 16-bit types with VK_KHR_16bit_storages implies that push constant offsets could be multiple of 2-bytes. Some assertions are updated so offsets should be just multiple of size of the base type but in some cases we can not assume it as doubles aren't aligned to 8 bytes in some cases. For 16-bit types, the push constant offset takes into account the internal offset in the 32-bit uniform bucket adding 2-bytes when we access not 32-bit aligned elements. In all 32-bit aligned cases it just becomes 0. v2: Assert offsets to be aligned to the dest type size. (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: Calculate properly 16-bit vector sizesJose Maria Casanova Crespo2018-02-281-5/+2
| | | | | | | | | | | Range in 16-bit push constants load was being calculated wrongly using 4-bytes per element instead of 2-bytes as it should be. v2: Use glsl_get_bit_size instead of if statement (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: apply memory qualifiers to imagesSamuel Pitoiset2018-02-221-3/+9
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* spirv: split constant initializers on in/out structsIago Toral Quiroga2018-02-061-0/+8
| | | | | | | | | The SPIR-V parser splits in/out struct variables and creates a separate variable for each first-level member of the struct. When the struct variable has an initializer this means that we also need to split the initializer. Reviewed-by: Jason Ekstrand <[email protected]>
* .gitignore: Ignore new generated filesScott D Phillips2018-01-081-0/+1
| | | | | | | | | New generated files from: bb1e6ff161c ("spirv: Add a prepass to set types on vtn_values") 65fc16c9741 ("autotools: set XA versions in configure.ac and configure header file") Reviewed-by: Jordan Justen <[email protected]>
* spirv: Do implicit conversions of uint to bool in OpStoreJason Ekstrand2018-01-081-0/+19
| | | | | | | | | | | Technically, the GLSLang bug related to this can also affect SSBO writes where the bool -> uint conversion is missing. However, the only known shipping application with an old enough version of GLSLang to cause issues with this is the new DOOM game so we keep the workaround as small as possible. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104424 Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Loosen the validation for load/store type matchingJason Ekstrand2018-01-081-6/+33
| | | | | | | Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104338 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104424 Tested-by: Eero Tamminen <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Require a storage type for OpStore destinationsJason Ekstrand2018-01-081-0/+4
| | | | | | | This rules out things such as trying to store a pointer to a local variable. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Add a vtn_types_compatible helperJason Ekstrand2018-01-082-0/+55
| | | | | Tested-by: Eero Tamminen <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Store the id of the type in vtn_typeJason Ekstrand2018-01-083-5/+8
| | | | | | | | | Previously, we were storing a pointer to the vtn_value because we use it to look up decorations when we create input/output variables. This works, but it also may be useful to have the id itself so we may as well store that instead. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Add a mechanism for dumping failing shadersJason Ekstrand2018-01-082-0/+29
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Rework asserts in var_decoration_cbJason Ekstrand2018-01-081-7/+8
| | | | | | | | Now that higher levels are enforcing decoration sanity, we don't need the vtn_asserts here. This function *should* be safe but we still want a few well-placed regular asserts in case something goes awry. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Rework error checking for decorationsJason Ekstrand2018-01-081-9/+32
| | | | | | | | | | | | This reworks the error checking on our generic handling of decorations. The objective is to validate all of the SPIR-V assumptions we make up-front and convert redundant checks to compiled-out asserts. The most important part of this is to ensure that member decorations only occur on OpTypeStruct and that the member is never out-of-bounds. This way later code can assume that the member is sane and not have to worry about OOB array access due to a misplaced OpMemberDecorate. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Add better type validation to OpTypeImageJason Ekstrand2018-01-081-7/+10
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Switch on vtn_base_type in OpComposite(Extract|Insert)Jason Ekstrand2018-01-081-37/+32
| | | | | | | | This is a bit simpler since we have fewer enum values in the case. It's also a bit more efficient because we're making fewer glsl_get_* calls. While we're at it, add better type validation. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Refactor Op[Spec]ConstantComposite and add better validationJason Ekstrand2018-01-081-36/+32
| | | | | | | | Now that vtn_base_type is a real and full base type, we can switch on that instead of the GLSL base type which is a lot fewer cases in our switch. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Add better validation to Op[Spec]ConstantJason Ekstrand2018-01-081-2/+7
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Remove a pointless assignment in SpvOpSpecConstantJason Ekstrand2018-01-081-1/+0
| | | | | | We re-assign later inside the bit_size switch Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Unify boolean constants and add better validationJason Ekstrand2018-01-081-10/+11
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv/info: Add spirv_op_to_stringJason Ekstrand2018-01-082-0/+11
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Make 'info' a local array spirv_info_c.pyJason Ekstrand2018-01-081-3/+5
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Add better error messages in vtn_value helpersJason Ekstrand2018-01-081-11/+15
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Import 1.2 rev 3 headers and grammar from KhronosCaio Marcelo de Oliveira Filho2018-01-082-164/+431
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: consider bitsize when handling OpSwitch casesEero Tamminen2017-12-281-3/+11
| | | | | | | | | | | | This reverts commit 7665383a33f9ce9256aa121cbe4d3bd948dff145 and is squashed together with https://patchwork.freedesktop.org/patch/194610/ (spirv: avoid infinite loop / freeze in vtn_cfg_walk_blocks()) which fixes https://bugs.freedesktop.org/show_bug.cgi?id=104359 properly. Fixes: 9702fac68e (spirv: consider bitsize when handling OpSwitch cases) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104359 Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* Revert "spirv: consider bitsize when handling OpSwitch cases"Mark Janes2017-12-211-11/+3
| | | | | | | | | | This reverts commit 9702fac68e8bd07be8871f7925d7f9fb98da3699, which hangs vulkancts and crucible on all platforms. The patch is being reverted because it disables continuous integration testing. The patch from bug 104359 does not apply to master. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104359
* spirv: consider bitsize when handling OpSwitch casesJuan A. Suarez Romero2017-12-201-3/+11
| | | | | | | When walking over all the cases in a OpSwitch, take in account the bitsize of the literals to avoid getting wrong cases. Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: Relax the validation conditions of OpSelectJason Ekstrand2017-12-181-4/+21
| | | | | | | | | | | The Talos Principle contains shaders with an OpSelect between two vectors where the condition is a scalar boolean. This is technically against the spec bout nir_builder gracefully handles it by splatting out the condition to all the channels. So long as the condition is a boolean, just emit a warning instead of failing. Reviewed-by: Lionel Landwerlin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104246
* spirv: Handle image and sampler function parametersJason Ekstrand2017-12-121-0/+73
|
* spirv/cfg: Refactor the function parameter loop a bitJason Ekstrand2017-12-121-5/+9
|
* spirv/cfg: Be a bit more precise about function parametersJason Ekstrand2017-12-121-3/+2
| | | | | | Pointers with no storage type are converted to inout variables but SSA values and pointers with a storage type (which turns into a uint or uvec2) are just input variables.
* spirv: Make sampled images a real typeJason Ekstrand2017-12-122-1/+11
| | | | | | | Previously, we just gave them exactly the same type as the respective image (which already had a sampler2D or similar type). Now they have their own base type and a pointer to the vtn_type for the image. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* spirv: Add support for all bit sizes in OpSwitchJason Ekstrand2017-12-111-8/+26
| | | | | Reviewed-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101560
* spirv: Restructure the case loop in OpSwitch handlingJason Ekstrand2017-12-111-3/+11
| | | | | | | | | Instead of calling vtn_add_case for the default case and then looping, add an is_default variable and do everything inside the loop. This will make the next commit easier. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* spirv: Add better parameter validation for vector and matrix typesJason Ekstrand2017-12-111-3/+13
| | | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* spirv: Add type validation for OpSelectJason Ekstrand2017-12-111-0/+32
| | | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* spirv: Add basic type validation for OpLoad, OpStore, and OpCopyMemoryJason Ekstrand2017-12-111-4/+14
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* spirv: Add a prepass to set types on vtn_valuesJason Ekstrand2017-12-113-1/+133
| | | | | | | | This autogenerated pass will automatically find and set the type field on all vtn_values. This way we always have the type and can use it for validation and other checks. Reviewed-by: Ian Romanick <[email protected]>
* spirv: Add a vtn_type field to all vtn_valuesJason Ekstrand2017-12-112-42/+31
| | | | | | | | | At the moment, this just lets us drop the const_type for constants and unify things a bit. Eventually, we will use this to store the types of all SPIR-V SSA values. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* spirv: Allow ignoring decorations for workgroup variablesJason Ekstrand2017-12-111-1/+3
| | | | | | | | | | Since we switched over to lowering SLM access directly in SPIR-V -> NIR, we no longer have vtn_variables for SLM. It's all safe as with UBOs and SSBOs but we need to let it through in the assert. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104213 Fixes: 8761a04d0d9332d9c0c99164faf855fc3c741f7c Reviewed-by: Jordan Justen <[email protected]>
* spirv: Set lengths on scalar and vector typesJason Ekstrand2017-12-111-0/+4
| | | | Reviewed-by: Ian Romanick <[email protected]>
* spirv: Fix loading an entire block at once.Bas Nieuwenhuizen2017-12-101-30/+33
| | | | | | | | | There is no chain, so checking the length ends with a SEGFAULT. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103579 Cc: <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/spirv: move and rename nir_spirv_supported_capabilitiesAlejandro Piñeiro2017-12-071-2/+2
| | | | | | | | | | To avoid any vulkan driver to include the GL mtypes.h. Renamed as eventually this could be used by drivers not using nir. v2: remove compiler/spirv/spirv.h from mtypes (Alejandro) v3: added the definition at compiler/shader_info.h (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: fix bug when OpSpecConstantOp calls a conversionSamuel Iglesias Gonsálvez2017-12-071-6/+21
| | | | | | | | | | | | | | | | | In that case, nir_eval_const_opcode() will evaluate the conversion but as it was using destination's bit_size, the resulting value was just a cast of the source constant value. By passing the source's bit size, it does the conversion properly. Fixes: dEQP-VK.spirv_assembly.instruction.*.opspecconstantop.*convert* v2: - Remove invalid conversion op cases. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* spirv: allow specialization constants with bitsize different than 32 bitsSamuel Iglesias Gonsálvez2017-12-071-1/+0
| | | | | Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: define nir_spirv_supported_capabilitiesAlejandro Piñeiro2017-12-061-13/+3
| | | | | | | | | Until now it was part of spirv_to_nir_options. But it will be used on the implementation of ARB_gl_spirv and ARB_spirv_extensions, and added to the OpenGL context, as a way to save what SPIR-V capabilities the current OpenGL implementation supports. Reviewed-by: Ian Romanick <[email protected]>
* spirv/nir: Add support for SPV_KHR_16bit_storageEduardo Lima Mitev2017-12-062-0/+8
| | | | | | | v2: Minor changes after rebase against recent master (Alejandro Pinheiro) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: Enable FPRoundingMode decorator to nir operationsJose Maria Casanova Crespo2017-12-061-0/+33
| | | | | | | | | | | | SpvOpFConvert now manages the FPRoundingMode decorator for the returning values enabling the nir_rounding_mode in the conversion operation to fp16 values. v2: Fixed breaking of specialization constants. (Jason Ekstrand) v3: Avoid nir_rounding_mode * casting. (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv/nir: Handle 16-bit typesEduardo Lima Mitev2017-12-062-19/+114
| | | | | | | | | | | | | | v2: Added more missing implementations of 16-bit types. (Jason Ekstrand) v3: Store values in values[0].u16[i] (Jason Ekstrand) Include switches based on bitsize for 16-bit types (Chema Casanova) v4: Coding style fixes (Jason Ekstrand) Use vtn_u64_literal and u64[0] at 64-bit SpvOpConstant (Jason Ekstrand) Signed-off-by: Jose Maria Casanova Crespo <[email protected]> Signed-off-by: Eduardo Lima <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Handle fp16 rounding modes at nir_type_conversion_opJose Maria Casanova Crespo2017-12-061-1/+1
| | | | | | | | | | | | | | | | | nir_type_conversion enables new operations to handle rounding modes to convert to fp16 values. Two new opcodes are enabled nir_op_f2f16_rtne and nir_op_f2f16_rtz. The undefined behaviour doesn't has any effect and uses the original nir_op_f2f16 operation. v2: Indentation fixed (Jason Ekstrand) v3: Use explicit case for undefined rounding and assert if rounding mode is used for non 16-bit float conversions (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* spirv: Allow OpPtrAccessChain for block indicesJason Ekstrand2017-12-051-46/+102
| | | | | | | | | | | | | | | | | | | | | | | The SPIR-V spec is a bit underspecified when it comes to exactly how you're allowed to use OpPtrAccessChain and what it means in certain edge cases. In particular, what if the base pointer of the OpPtrAccessChain points to the base struct of an SSBO instead of an element in that SSBO. The original variable pointers implementation in mesa assumed that you weren't allowed to do an OpPtrAccessChain that adjusted the block index and asserted such. However, there are some CTS tests that do this and, if the CTS does it, someone will do it in the wild so we should probably handle it. With this commit, we significantly reduce our assumptions and should be able to handle more-or-less anything. The one assumption we still make for correctness is that if we see an OpPtrAccessChain on a pointer to a struct decorated block that the block index should be adjusted. In theory, someone could try to put an array stride on such a pointer and try to make the SSBO an implicit array of the base struct and we would not give them what they want. That said, any index other than 0 would count as an out-of-bounds access which is invalid. Reviewed-by: Kristian H. Kristensen <[email protected]>