~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH gio 0/1] Adding windows compute shader compilation

~egonelbre
Details
Message ID
<161383179564.28955.17325874054897870871-0@git.sr.ht>
DKIM signature
missing
Download raw message
I started looking into implementing comp shaders for Windows and hit a
few errors with the shaders that I'm not sure how to solve.

I've
listed the errors that should make things compile. Some of these might
be errors in glsl as well, not just hlsl, based on the comment I found
in https://github.com/microsoft/DirectXShaderCompiler/issues/1306.

>
error X3663: thread sync operation found in varying flow control,
consider reformulating your algorithm so all threads will hit the sync
simultaneously:

backdrop.comp (and few others):

    void main() {
if (mem_error != NO_ERROR) {
            return;
        }
...
        barrier();

> error X3000: syntax error: unexpected token
'vector':

    struct TileSeg {
        vec2 origin;
        vec2
vector; // <--- it looks like "vector" is a reserved word.
float y_edge;
        TileSegRef next;

> kernel4.comp: error X3708:
continue cannot be used in a switch

    case Cmd_Jump:
cmd_ref = CmdRef(Cmd_Jump_read(cmd_alloc, cmd_ref).new_ref);
cmd_alloc.offset = cmd_ref.offset;
        continue;

> error X4026:
thread sync operation must be in non-varying flow control, due to a
potential race condition this sync is illegal, consider adding a sync
after reading any values controlling shader execution at this point
MallocResult alloc_clip_buf(uint link) {
        if
(gl_LocalInvocationID.x == 0 && gl_LocalInvocationID.y == 0) {
MallocResult m = malloc(CLIP_BUF_SIZE * 4);
            if (!m.failed)
{
                write_mem(m.alloc, (m.alloc.offset >> 2) +
CLIP_LINK_OFFSET, link);
            }
            sh_clip_alloc = m;
}
        barrier();
        return sh_clip_alloc;
    }

Egon Elbre (1):
  internal/cmd/convertshaders: add Windows comp shader compilation

 internal/cmd/convertshaders/main.go | 67 +++++++++++++++++++++--------
 1 file changed, 49 insertions(+), 18 deletions(-)

-- 
2.30.1

[PATCH gio 1/1] internal/cmd/convertshaders: add Windows comp shader compilation

~egonelbre
Details
Message ID
<161383179564.28955.17325874054897870871-1@git.sr.ht>
In-Reply-To
<161383179564.28955.17325874054897870871-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
Patch: +49 -18
From: Egon Elbre <egonelbre@gmail.com>

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
---
 internal/cmd/convertshaders/main.go | 67 +++++++++++++++++++++--------
 1 file changed, 49 insertions(+), 18 deletions(-)

diff --git a/internal/cmd/convertshaders/main.go b/internal/cmd/convertshaders/main.go
index 1f481a1..5f36738 100644
--- a/internal/cmd/convertshaders/main.go
+++ b/internal/cmd/convertshaders/main.go
@@ -102,18 +102,21 @@ func generateComputeShader(tmp string, out io.Writer, shader string) error {
		return err
	}
	var src backend.ShaderSources
	glsl310es, err := convertComputeShader(tmp, glslangValidator, spirv_cross, shader)
	shaders, err := convertComputeShader(tmp, glslangValidator, spirv_cross, shader)
	if err != nil {
		return err
	}
	src.Name = filepath.Base(shader)
	src.GLSL310ES = glsl310es
	src.GLSL310ES = shaders.glsl310es

	name := filepath.Base(shader)
	name = strings.ReplaceAll(name, ".", "_")
	fmt.Fprintf(out, "\tshader_%s = ", name)
	fmt.Fprintf(out, "backend.ShaderSources{\n")
	fmt.Fprintf(out, "Name: %#v,\n", src.Name)
	fmt.Fprintf(out, "GLSL310ES: %#v,\n", src.GLSL310ES)
	fmt.Fprintf(out, "/*\n%s\n*/\n", shaders.hlslSrc)
	fmt.Fprintf(out, "HLSL: %#v,\n", shaders.hlsl)
	fmt.Fprintf(out, "}")
	fmt.Fprintf(out, "\n")
	return nil
@@ -449,9 +452,6 @@ func convertShader(tmp, glslcc, path, lang, profile string, args *shaderArgs, fl
	case ".frag":
		progFlag = "--frag"
		progSuffix = "fs"
	case ".comp":
		progFlag = "--compute"
		progSuffix = "cs"
	default:
		return "", nil, fmt.Errorf("unrecognized shader type: %s", path)
	}
@@ -493,7 +493,13 @@ func convertShader(tmp, glslcc, path, lang, profile string, args *shaderArgs, fl
	return string(src), reflect, nil
}

func convertComputeShader(tmp, glslangValidator, spirv_cross, path string) (string, error) {
type computeShaders struct {
	glsl310es string
	hlslSrc   string
	hlsl      []byte
}

func convertComputeShader(tmp, glslangValidator, spirv_cross, path string) (computeShaders, error) {
	spvFile := filepath.Join(tmp, "shader.spv")
	cmd := exec.Command(glslangValidator,
		"-G100", // OpenGL ES 3.1.
@@ -505,18 +511,43 @@ func convertComputeShader(tmp, glslangValidator, spirv_cross, path string) (stri
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		return "", fmt.Errorf("%s: %v", strings.Join(cmd.Args, " "), err)
		return computeShaders{}, fmt.Errorf("%s: %v", strings.Join(cmd.Args, " "), err)
	}
	cmd = exec.Command(spirv_cross,
		"--es",
		"--version", "310",
		spvFile,
	)
	var shaderDump bytes.Buffer
	cmd.Stdout = &shaderDump
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		return "", fmt.Errorf("%s: %v", strings.Join(cmd.Args, " "), err)

	var output computeShaders
	{
		cmd = exec.Command(spirv_cross,
			"--es",
			"--version", "310",
			spvFile,
		)
		var shaderDump bytes.Buffer
		cmd.Stdout = &shaderDump
		cmd.Stderr = os.Stderr
		if err := cmd.Run(); err != nil {
			return output, fmt.Errorf("%s: %v", strings.Join(cmd.Args, " "), err)
		}
		output.glsl310es = shaderDump.String()
	}
	{
		cmd = exec.Command(spirv_cross,
			"--hlsl",
			"--shader-model", "50",
			spvFile,
		)
		var shaderDump bytes.Buffer
		cmd.Stdout = &shaderDump
		cmd.Stderr = os.Stderr
		if err := cmd.Run(); err != nil {
			return output, fmt.Errorf("%s: %v", strings.Join(cmd.Args, " "), err)
		}
		output.hlslSrc = shaderDump.String()

		var err error
		output.hlsl, err = compileHLSL(tmp, path, output.hlslSrc, "main", "cs_5_0")
		if err != nil {
			return output, err
		}
	}
	return shaderDump.String(), nil
	return output, nil
}
-- 
2.30.1

[gio/patches] build failed

builds.sr.ht
Details
Message ID
<C9EFY71IWSV2.HZE652ZFCKOZ@cirno>
In-Reply-To
<161383179564.28955.17325874054897870871-1@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
gio/patches: FAILED in 15m9s

[Adding windows compute shader compilation][0] from [~egonelbre][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/20383
[1]: mailto:egonelbre@gmail.com

✓ #432260 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/432260
✓ #432261 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/432261
✓ #432263 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/432263
✗ #432262 FAILED  gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/432262
Reply to thread Export thread (mbox)