Skip to content

[HLSL] Add matrix tests for degrees(), radians() - #1475

Open
danbrown-amd wants to merge 1 commit into
llvm:mainfrom
danbrown-amd:degrees_mat
Open

[HLSL] Add matrix tests for degrees(), radians()#1475
danbrown-amd wants to merge 1 commit into
llvm:mainfrom
danbrown-amd:degrees_mat

Conversation

@danbrown-amd

Copy link
Copy Markdown
Collaborator

Resolves #787, #790

Assisted-by: Claude Opus 4

@farzonl farzonl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@kmpeng
kmpeng self-requested a review August 25, 2026 22:37

@kmpeng kmpeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mostly have the same comments as I've had in other PRs.


[numthreads(1,1,1)]
void main() {
float3x2 r32 = degrees(float3x2(In[0].xy, In[0].zw, In[1].xy));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(For all files)
Same as the other PRs. Capitalize variable names

Comment on lines +7 to +10
float3x2 r32 = degrees(float3x2(In[0].xy, In[0].zw, In[1].xy));
float2x4 r24 = degrees(float2x4(In[1], In[2]));
float3x1 r31 = degrees(float3x1(In[0].x, In[2].x, In[2].y));
float4x4 r44 = degrees(float4x4(In[0], In[1], In[2], In[3]));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(For all files)
Same as the other PRs. The indexing here makes it kind of hard to follow/verify values. Can we just add more values and index one row per element like other matrix tests do?

float3x2 r32 = degrees(float3x2(In[0].xy, In[0].zw, In[1].xy));
float2x4 r24 = degrees(float2x4(In[1], In[2]));
float3x1 r31 = degrees(float3x1(In[0].x, In[2].x, In[2].y));
float4x4 r44 = degrees(float4x4(In[0], In[1], In[2], In[3]));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(For all files)
Same as the other PRs, there should be a constant folding case.

Comment on lines +12 to +19
Out[0] = float4(r32[0], 0.0, 0.0);
Out[1] = float4(r32[1], 0.0, 0.0);
Out[2] = float4(r32[2], 0.0, 0.0);
Out[3] = r24[0];
Out[4] = r24[1];
Out[5] = float4(r31[0], 0.0, 0.0, 0.0);
Out[6] = float4(r31[1], 0.0, 0.0, 0.0);
Out[7] = float4(r31[2], 0.0, 0.0, 0.0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(For all files)
Same as the other PRs. You have a lot of dead space in Out the way you're packing it.

Binding: 1
#--- end

# Unimplemented: https://github.com/llvm/llvm-project/issues/184480

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(For all files)
Same as the other PRs.

Suggested change
# Unimplemented: https://github.com/llvm/llvm-project/issues/184480
# Unimplemented https://github.com/llvm/llvm-project/issues/184480

@@ -0,0 +1,96 @@
#--- source.hlsl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as other PRs. I don't think we need fp16 matrix tests for these intrinsics.

Comment on lines +40 to +43
# In[0]: 0, pi/6, pi/4, pi/3
# In[1]: pi/2, pi, 3pi/2, 2pi
# In[2]: -pi/4, -pi/2, -pi, pi/12
# In[3]: pi/6, pi/2, pi/12, pi/4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I feel labeling In[0], In[1], etc. doesn't really add anything

Comment on lines +59 to +70
# Out[0]: r32[0]: 0, pi/6 (+ pad)
# Out[1]: r32[1]: pi/4, pi/3 (+ pad)
# Out[2]: r32[2]: pi/2, pi (+ pad)
# Out[3]: r24[0]: pi/2, pi, 3pi/2, 2pi
# Out[4]: r24[1]: -pi/4, -pi/2, -pi, pi/12
# Out[5]: r31[0]: 0 (+ pad)
# Out[6]: r31[1]: -pi/4 (+ pad)
# Out[7]: r31[2]: -pi/2 (+ pad)
# Out[8]: r44[0]: 0, pi/6, pi/4, pi/3
# Out[9]: r44[1]: pi/2, pi, 3pi/2, 2pi
# Out[10]: r44[2]: -pi/4, -pi/2, -pi, pi/12
# Out[11]: r44[3]: pi/6, pi/2, pi/12, pi/4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Same as degrees, I feel labeling Out[0] etc. doesn't really add anything. Also it's confusing to have with the r__ labels.

I think a better way to annotate these are to group by matrix shape and use _ as padding like other matrix tests do. For example:

# 3x2: 8, 2, 3, 2, 5, 64, _, _
# 2x4: 2, 16, 512, 4, 1.732422, 16, 2.236328, 8
# 3x1: 8, 3, 64, _
# 4x4: 1.414062, 2, 4, 16, 1, 10, 3.162109, 0.5,
# 1, 3, 9, 27, 2, 4, 16, 3
# 2x2 const: 1.414062, 2, 4, 16

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.

[Matrix] Add matrix test for degrees

3 participants