radeonsi: remove glsl_tests subdirectory

This hasn't been used for 9 years.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38802>
This commit is contained in:
Marek Olšák 2025-11-21 23:18:02 -05:00 committed by Marge Bot
parent 041cde6aa1
commit 81adf1ea71
21 changed files with 0 additions and 778 deletions

View file

@ -1,8 +0,0 @@
Type "meson build && meson compile -C build" to build amdgcn_glslc.
amdgcn_glslc works only if radeonsi_dri.so is loaded by libGL.
It's just a GL application that sets R600_DEBUG and captures stderr.
To run the tests, use llvm-lit from your llvm checkout and run:
llvm-lit -v *.glsl

View file

@ -1,275 +0,0 @@
/*
* Copyright © 2014 Intel Corporation
* Copyright © 2016 Advanced Micro Devices, Inc.
*
* SPDX-License-Identifier: MIT
*/
/**
* This program reads and compiles multiple GLSL shaders from one source file.
* Each shader must begin with the #shader directive. Syntax:
* #shader [vs|tcs|tes|gs|ps|cs] [name]
*
* The shader name is printed, followed by the stderr output from
* glCreateShaderProgramv. (radeonsi prints the shader disassembly there)
*
* The optional parameter -mcpu=[processor] forces radeonsi to compile for
* the specified GPU processor. (e.g. tahiti, bonaire, tonga)
*
* The program doesn't check if the underlying driver is really radeonsi.
* OpenGL 4.3 Core profile is required.
*/
/* for asprintf() */
#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <epoxy/gl.h>
#include <epoxy/egl.h>
#include <gbm.h>
#define unlikely(x) __builtin_expect(!!(x), 0)
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static int fd;
static EGLDisplay egl_dpy;
static EGLContext ctx;
static void
create_gl_core_context()
{
const char *client_extensions = eglQueryString(EGL_NO_DISPLAY,
EGL_EXTENSIONS);
if (!client_extensions) {
fprintf(stderr, "ERROR: Missing EGL_EXT_client_extensions\n");
exit(1);
}
if (!strstr(client_extensions, "EGL_MESA_platform_gbm")) {
fprintf(stderr, "ERROR: Missing EGL_MESA_platform_gbm\n");
exit(1);
}
fd = open("/dev/dri/renderD128", O_RDWR);
if (unlikely(fd < 0)) {
fprintf(stderr, "ERROR: Couldn't open /dev/dri/renderD128\n");
exit(1);
}
struct gbm_device *gbm = gbm_create_device(fd);
if (unlikely(gbm == NULL)) {
fprintf(stderr, "ERROR: Couldn't create gbm device\n");
exit(1);
}
egl_dpy = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA,
gbm, NULL);
if (unlikely(egl_dpy == EGL_NO_DISPLAY)) {
fprintf(stderr, "ERROR: eglGetDisplay() failed\n");
exit(1);
}
if (unlikely(!eglInitialize(egl_dpy, NULL, NULL))) {
fprintf(stderr, "ERROR: eglInitialize() failed\n");
exit(1);
}
static const char *egl_extension[] = {
"EGL_KHR_create_context",
"EGL_KHR_surfaceless_context"
};
const char *extension_string = eglQueryString(egl_dpy, EGL_EXTENSIONS);
for (int i = 0; i < ARRAY_SIZE(egl_extension); i++) {
if (strstr(extension_string, egl_extension[i]) == NULL) {
fprintf(stderr, "ERROR: Missing %s\n", egl_extension[i]);
exit(1);
}
}
static const EGLint config_attribs[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_NONE
};
EGLConfig cfg;
EGLint count;
if (!eglChooseConfig(egl_dpy, config_attribs, &cfg, 1, &count) ||
count == 0) {
fprintf(stderr, "ERROR: eglChooseConfig() failed\n");
exit(1);
}
eglBindAPI(EGL_OPENGL_API);
static const EGLint attribs[] = {
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_CONTEXT_MAJOR_VERSION_KHR, 4,
EGL_CONTEXT_MINOR_VERSION_KHR, 3,
EGL_NONE
};
ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
if (ctx == EGL_NO_CONTEXT) {
fprintf(stderr, "eglCreateContext(GL 3.2) failed.\n");
exit(1);
}
if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
fprintf(stderr, "eglMakeCurrent failed.\n");
exit(1);
}
}
static char *
read_file(const char *filename)
{
FILE *f = fopen(filename, "r");
if (!f) {
fprintf(stderr, "Can't open file: %s\n", filename);
exit(1);
}
fseek(f, 0, SEEK_END);
int filesize = ftell(f);
fseek(f, 0, SEEK_SET);
char *input = (char*)malloc(filesize + 1);
if (!input) {
fprintf(stderr, "malloc failed\n");
exit(1);
}
if (fread(input, filesize, 1, f) != 1) {
fprintf(stderr, "fread failed\n");
exit(1);
}
fclose(f);
input[filesize] = 0;
return input;
}
static void addenv(const char *name, const char *value)
{
const char *orig = os_get_option(name);
if (orig) {
char *newval;
(void)!asprintf(&newval, "%s,%s", orig, value);
os_set_option(name, newval, true);
free(newval);
} else {
os_set_option(name, value, true);
}
}
int
main(int argc, char **argv)
{
const char *filename = NULL;
for (int i = 1; i < argc; i++) {
if (strstr(argv[i], "-mcpu=") == argv[i]) {
os_set_option("AMD_FORCE_FAMILY", argv[i] + 6, true);
} else if (filename == NULL) {
filename = argv[i];
} else {
if (strcmp(argv[i], "--help") != 0 && strcmp(argv[i], "-h") != 0)
fprintf(stderr, "Unknown option: %s\n\n", argv[i]);
fprintf(stderr, "Usage: amdgcn_glslc -mcpu=[chip name] [glsl filename]\n");
return 1;
}
}
if (filename == NULL) {
fprintf(stderr, "No filename specified.\n");
return 1;
}
addenv("R600_DEBUG", "precompile,vs,tcs,tes,gs,ps,cs,noir,notgsi");
create_gl_core_context();
/* Read the source. */
char *input = read_file(filename);
/* Comment out lines beginning with ; (FileCheck prefix). */
if (input[0] == ';')
memcpy(input, "//", 2);
char *s = input;
while (s = strstr(s, "\n;"))
memcpy(s + 1, "//", 2);
s = input;
while (s && (s = strstr(s, "#shader "))) {
char type_str[16], name[128];
GLenum type;
/* If #shader is not at the beginning of the line. */
if (s != input && s[-1] != '\n' && s[-1] != 0) {
s = strstr(s, "\n");
continue;
}
/* Parse the #shader directive. */
if (sscanf(s + 8, "%s %s", type_str, name) != 2) {
fprintf(stderr, "Cannot parse #shader directive.\n");
continue;
}
if (!strcmp(type_str, "vs"))
type = GL_VERTEX_SHADER;
else if (!strcmp(type_str, "tcs"))
type = GL_TESS_CONTROL_SHADER;
else if (!strcmp(type_str, "tes"))
type = GL_TESS_EVALUATION_SHADER;
else if (!strcmp(type_str, "gs"))
type = GL_GEOMETRY_SHADER;
else if (!strcmp(type_str, "fs"))
type = GL_FRAGMENT_SHADER;
else if (!strcmp(type_str, "cs"))
type = GL_COMPUTE_SHADER;
/* Go the next line. */
s = strstr(s, "\n");
if (!s)
break;
s++;
const char *source = s;
/* Cut the shader source at the end. */
s = strstr(s, "#shader");
if (s && s[-1] == '\n')
s[-1] = 0;
/* Compile the shader. */
printf("@%s:\n", name);
/* Redirect stderr to stdout for the compiler. */
FILE *stderr_original = stderr;
stderr = stdout;
GLuint prog = glCreateShaderProgramv(type, 1, &source);
stderr = stderr_original;
GLint linked;
glGetProgramiv(prog, GL_LINK_STATUS, &linked);
if (!linked) {
char log[4096];
GLsizei length;
glGetProgramInfoLog(prog, sizeof(log), &length, log);
fprintf(stderr, "ERROR: Compile failure:\n\n%s\n%s\n",
source, log);
return 1;
}
glDeleteProgram(prog);
}
return 0;
}

View file

@ -1,15 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@bitcount:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_bcnt_u32
; GCN-NEXT: epilog
#shader fs bitcount
#version 400
flat in int i;
out ivec4 o;
void main() {
o.x = bitCount(i);
}

View file

@ -1,34 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@bfe_i32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_bfe_i32
; GCN-NEXT: epilog
#shader fs bfe_i32
#version 400
flat in ivec3 v;
out ivec4 o;
void main() {
o.x = bitfieldExtract(v.x, v.y, v.z);
}
; FUNC-LABEL: {{^}}@bfe_u32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_bfe_u32
; GCN-NEXT: epilog
#shader fs bfe_u32
#version 400
flat in uvec3 v;
out uvec4 o;
void main() {
o.x = bitfieldExtract(v.x, int(v.y), int(v.z));
}

View file

@ -1,40 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@bfi_i32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_bfm_b32
; GCN-NEXT: v_lshlrev_b32
; GCN-NEXT: v_bfi_b32
; GCN-NEXT: epilog
#shader fs bfi_i32
#version 400
flat in ivec4 v;
out ivec4 o;
void main() {
o.x = bitfieldInsert(v.x, v.y, v.z, v.w);
}
; FUNC-LABEL: {{^}}@bfi_u32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_bfm_b32
; GCN-NEXT: v_lshlrev_b32
; GCN-NEXT: v_bfi_b32
; GCN-NEXT: epilog
#shader fs bfi_u32
#version 400
flat in uvec4 v;
out uvec4 o;
void main() {
o.x = bitfieldInsert(v.x, v.y, int(v.z), int(v.w));
}

View file

@ -1,30 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@div:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_rcp_f32
; GCN-NEXT: v_mul_f32
; GCN-NEXT: epilog
#shader fs div
#version 400
flat in vec2 v;
void main() {
gl_FragColor.x = v.x / v.y;
}
; FUNC-LABEL: {{^}}@rcp:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_rcp_f32
; GCN-NEXT: epilog
#shader fs rcp
#version 400
flat in float x;
void main() {
gl_FragColor.x = 1 / x;
}

View file

@ -1,14 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@exp2:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_exp_f32
; GCN-NEXT: epilog
#shader fs exp2
#version 400
flat in float f;
void main() {
gl_FragColor.x = exp2(f);
}

View file

@ -1,16 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@fma:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_mac_f32
; GCN-NEXT: epilog
#shader fs fma
#version 400
flat in vec3 v;
void main() {
gl_FragColor.x = fma(v.x, v.y, v.z);
}

View file

@ -1,21 +0,0 @@
; RUN: ./amdgcn_glslc -mcpu=tahiti %s | FileCheck -check-prefix=GCN -check-prefix=FUNC -check-prefix=SI %s
; RUN: ./amdgcn_glslc -mcpu=bonaire %s | FileCheck -check-prefix=GCN -check-prefix=FUNC -check-prefix=CI %s
; RUN: ./amdgcn_glslc -mcpu=tonga %s | FileCheck -check-prefix=GCN -check-prefix=FUNC -check-prefix=CI %s
; Only SI has buggy v_fract and must use v_floor.
; The amdgcn.fract intrinsic can be used only if LLVM passes are able to move it.
; FUNC-LABEL: {{^}}@fract:
; GCN: main
; GCN: v_interp_mov
; SI-NEXT: v_floor_f32
; SI-NEXT: v_subrev_f32
; CI-NEXT: v_fract_f32
; GCN-NEXT: epilog
#shader fs fract
#version 400
flat in float f;
void main() {
gl_FragColor.x = fract(f);
}

View file

@ -1,15 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@frexp:
; GCN: main
; GCN: v_interp_mov
; GCN-DAG: v_frexp_mant_f32
; GCN-DAG: v_frexp_exp_i32_f32
; GCN-NEXT: epilog
#shader fs frexp
#version 400
flat in float f;
void main() {
gl_FragColor.x = frexp(f, gl_FragColor.y);
}

View file

@ -1,16 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@ldexp:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_ldexp_f32
; GCN-NEXT: epilog
#shader fs ldexp
#version 400
flat in float f;
flat in int i;
void main() {
gl_FragColor.x = ldexp(f, i);
}

View file

@ -1,27 +0,0 @@
# -*- Python -*-
# Configuration file for the 'lit' test runner.
import os
import sys
import re
import platform
import lit.util
import lit.formats
# name: The name of this test suite.
config.name = 'AMDGCN_GLSL'
execute_external = True
# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.ShTest(execute_external)
import __main__
llvm_obj_root = __main__.llvm_obj_root
llvm_tools_dir = os.path.join(llvm_obj_root, 'bin')
# Tweak the PATH to include the tools dir.
path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
config.environment['PATH'] = path

View file

@ -1,14 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@log2:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_log_f32
; GCN-NEXT: epilog
#shader fs log2
#version 400
flat in float f;
void main() {
gl_FragColor.x = log2(f);
}

View file

@ -1,13 +0,0 @@
# Copyright © 2016 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
project('glsl_tests', 'c')
dep_epoxy = dependency('epoxy')
dep_gbm = dependency('gbm')
executable(
'amdgcn_glslc',
files('amdgcn_glslc.c'),
dependencies: [dep_epoxy, dep_gbm]
)

View file

@ -1,30 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@min_f32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_min_f32
; GCN-NEXT: epilog
#shader fs min_f32
#version 400
flat in vec2 v;
void main() {
gl_FragColor.x = min(v.x, v.y);
}
; FUNC-LABEL: {{^}}@max_f32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_max_f32
; GCN-NEXT: epilog
#shader fs max_f32
#version 400
flat in vec2 v;
void main() {
gl_FragColor.x = max(v.x, v.y);
}

View file

@ -1,36 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@min_f64:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_min_f64
; GCN-NEXT: epilog
#shader fs min_f64
#version 400
flat in dvec2 v;
out uvec4 o;
void main() {
o.xy = unpackDouble2x32(min(v.x, v.y));
}
; FUNC-LABEL: {{^}}@max_f64:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_max_f64
; GCN-NEXT: epilog
#shader fs max_f64
#version 400
flat in dvec2 v;
out uvec4 o;
void main() {
o.xy = unpackDouble2x32(max(v.x, v.y));
}

View file

@ -1,32 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@min_i32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_min_i32
; GCN-NEXT: epilog
#shader fs min_i32
#version 400
flat in ivec2 v;
out ivec4 o;
void main() {
o.x = min(v.x, v.y);
}
; FUNC-LABEL: {{^}}@max_i32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_max_i32
; GCN-NEXT: epilog
#shader fs max_i32
#version 400
flat in ivec2 v;
out ivec4 o;
void main() {
o.x = max(v.x, v.y);
}

View file

@ -1,32 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@min_u32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_min_u32
; GCN-NEXT: epilog
#shader fs min_u32
#version 400
flat in uvec2 v;
out uvec4 o;
void main() {
o.x = min(v.x, v.y);
}
; FUNC-LABEL: {{^}}@max_u32:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_max_u32
; GCN-NEXT: epilog
#shader fs max_u32
#version 400
flat in uvec2 v;
out uvec4 o;
void main() {
o.x = max(v.x, v.y);
}

View file

@ -1,37 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; We don't want any "v_and" or "v_or" here. v_cvt_f16 only writes the lower 16 bits.
; FUNC-LABEL: {{^}}@packhalf:
; GCN: main
; GCN: v_interp_mov
; GCN: v_interp_mov
; GCN-NEXT: v_cvt_f16_f32
; GCN-NEXT: v_lshlrev_b32
; GCN-NEXT: v_cvt_f16_f32
; GCN-NEXT: epilog
#shader fs packhalf
#version 420
flat in vec2 v;
out uvec4 o;
void main() {
o.x = packHalf2x16(v);
}
; FUNC-LABEL: {{^}}@unpackhalf:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_cvt_f32_f16
; GCN-NEXT: v_lshrrev_b32
; GCN-NEXT: v_cvt_f32_f16
; GCN-NEXT: epilog
#shader fs unpackhalf
#version 420
flat in uint u;
out vec4 o;
void main() {
o.xy = unpackHalf2x16(u);
}

View file

@ -1,17 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@pow:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_log_f32
; GCN-NEXT: v_interp_mov
; GCN-NEXT: v_mul_legacy_f32
; GCN-NEXT: v_exp_f32
; GCN-NEXT: epilog
#shader fs pow
#version 400
flat in vec2 v;
void main() {
gl_FragColor.x = pow(v.x, v.y);
}

View file

@ -1,56 +0,0 @@
; RUN: ./amdgcn_glslc %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
; FUNC-LABEL: {{^}}@sqrt:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_sqrt_f32
; GCN-NEXT: epilog
#shader fs sqrt
#version 400
flat in float f;
void main() {
gl_FragColor.x = sqrt(f);
}
; FUNC-LABEL: {{^}}@inv_sqrt:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_rsq_f32
; GCN-NEXT: epilog
#shader fs inv_sqrt
#version 400
flat in float f;
void main() {
gl_FragColor.x = 1 / sqrt(f);
}
; FUNC-LABEL: {{^}}@rsq:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_rsq_f32
; GCN-NEXT: epilog
#shader fs rsq
#version 400
flat in float f;
void main() {
gl_FragColor.x = inversesqrt(f);
}
; FUNC-LABEL: {{^}}@inv_rsq:
; GCN: main
; GCN: v_interp_mov
; GCN-NEXT: v_sqrt_f32
; GCN-NEXT: epilog
#shader fs inv_rsq
#version 400
flat in float f;
void main() {
gl_FragColor.x = 1 / inversesqrt(f);
}