Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Language] Begin Basic.types #198

Merged
merged 11 commits into from
Apr 19, 2024
Merged

Conversation

llvm-beanz
Copy link
Collaborator

@llvm-beanz llvm-beanz commented Apr 15, 2024

This begins drafting the Basic.types section which specifies the foundations of HLSL's data types. This includes some basic information about representations as well as the classifications of types and the basic behaviors of some types.

Fixes #195

This begins drafting the Basic.types section which specifies the
foundations of HLSL's data types. This includes some basic information
about representations as well as the classifications of types and the
basic behaviors of some types.
specs/language/basic.tex Outdated Show resolved Hide resolved
specs/language/basic.tex Outdated Show resolved Hide resolved
specs/language/basic.tex Outdated Show resolved Hide resolved
specs/language/basic.tex Outdated Show resolved Hide resolved
specs/language/basic.tex Outdated Show resolved Hide resolved
specs/language/basic.tex Outdated Show resolved Hide resolved
I'm coining a new term "intangible classes" which is vaguely similar to
abstract classes except with less restrictions since you can create
instances of them, you just can't store them.

The later chapters will definitely need more work, but I think this gets
the bare bones across.
I think describing intangible types as the foundational bits (handles,
min-precision values, etc) and walking up from there makes more sense.
Then Resource types inherit being intangible.
(this actually fixes formatting, but I'll put it in separately).
@llvm-beanz
Copy link
Collaborator Author

The PDF build is here: https://github.com/microsoft/hlsl-specs/actions/runs/8724175011/artifacts/1422465192

In case anyone doesn't like reading LaTeX.

specs/language/basic.tex Outdated Show resolved Hide resolved
Copy link
Collaborator

@coopp coopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Glad this information is all captured now. Very interesting read for sure!

specs/language/basic.tex Outdated Show resolved Hide resolved
Copy link
Collaborator

@bogner bogner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better - I find the "intangible types" terminology and definitional approach much clearer than the "special types" wording from before.

Note: While I see classes.tex in the sources here, it doesn't seem to be rendered in the artifact here: https://github.com/microsoft/hlsl-specs/actions/runs/8726130788/artifacts/1422979344. Similarly, the "Intangible Types" page there is blank - is that missing or do you intend to put it there as a placeholder to be filled in later?

@llvm-beanz
Copy link
Collaborator Author

Note: While I see classes.tex in the sources here, it doesn't seem to be rendered in the artifact here: https://github.com/microsoft/hlsl-specs/actions/runs/8726130788/artifacts/1422979344. Similarly, the "Intangible Types" page there is blank - is that missing or do you intend to put it there as a placeholder to be filled in later?

I meant to delete classes.tex and somehow re-added it. Clearly git and I don't get along. It is removed now.

The classes and intangible types chapters are placeholders to be filled out later. I thought it was better to have references to empty sections rather than a bunch of TODO comments to add references later.

@bharadwajy
Copy link
Collaborator

Several (may be all?) of the definitions of the HLSL language concepts specified here appear (by design and choice, I presume) very similar to those of C++, for example types. If so, would it be prudent to defer to the public C++ specification for concepts that are the same in HLSL and C++ while providing details of concepts and support that is specific to HLSL and differ from C++? This could prevent ambiguous interpretation of concepts supported in both the languages owing to potentially different verbiage.

@llvm-beanz
Copy link
Collaborator Author

Several (may be all?) of the definitions of the HLSL language concepts specified here appear (by design and choice, I presume) very similar to those of C++, for example types. If so, would it be prudent to defer to the public C++ specification for concepts that are the same in HLSL and C++ while providing details of concepts and support that is specific to HLSL and differ from C++? This could prevent ambiguous interpretation of concepts supported in both the languages owing to potentially different verbiage.

In general, I think this is really great and important feedback. I've tried to cite the C and C++ specifications where possible. You'll note glossary references to isoC23, and isoCPP in this PR. I've also cited IEEE754 where I could instead of defining the floating point type representations. Unfortunately a lot of our behaviors are subtly different from C and C++, so citing the existing specifications doesn't really make sense.

For example in this PR, HLSL defines size-specified integer types, and the floating point type have explicitly defined sizes too. While we do satisfy C's guarantee that float is <= the size of double, in HLSL we can make a stronger guarantee. We also have the min-precision types which have completely different challenges. Because of those differences neither C nor C++'s definitions of arithmetic types fit HLSL.

Probably about the only direct overlap in this PR between HLSL and C++ is the definitions of object representation, value representation and object type. I deliberately chose to define those terms (even if slightly differently) so that the definition is in our document. My main reasoning is that it would suck when reading the spec to need to jump to another document to find a single-sentence term definition, and those definitions can move around between versions of the specification.

There is some shared language around Classes, but HLSL classes are very different from C++ so I really don't want to cite C++ too much in that part of the document because I don't want to mislead people into thinking the languages align more than they do.

For the purpose of this PR I think we have very little that we can directly inherit from C or C++ beyond what I've already cited without a whole lot of extra qualifying language (i.e. "It's like C++ but with these differences..."). If you think I missed something where we could more concisely just cite the C or C++ specification please let me know.

@llvm-beanz llvm-beanz merged commit 7f2de05 into microsoft:main Apr 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing specification of foundational types
6 participants