KhronosGroup / KhronosGroup/glslang

HLSL: possible to support default float precision qualifier?

Open
#1,790 1 comment 0 reactions 0 assignees View on GitHub
enhancement HLSL
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

In ESSL we use:

```
precision mediump float;
```

...such that computations involving variables declared as float will be treated as relaxed precision. As far as I can see, the way to get relaxed precision through to SPIR-V with the HLSL front end is to pass in EShMsgHlslEnable16BitTypes and then to use types such as half/half2/half3/half4.

Would it be possible to have the equivalent of a default precision for float's that could be specified in the shader code (or via a compiler invocation argument)? This would greatly simplify the (otherwise) manual process of converting to half precision.

Contributor guide

Open the contributing guide

Research direction

The issue names EShMsgHlslEnable16BitTypes and half/half2/half3/half4 as the current path; begin by tracing the HLSL front end's handling of those types and existing ESSL precision qualifiers. Compare shader-code and compiler-argument options, then confirm the chosen default-float behavior reaches relaxed SPIR-V without requiring manual conversions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.