Skip to content

Commit

Permalink
gles: Fix fallback path for pre-complied shaders
Browse files Browse the repository at this point in the history
This got borked a while back, causing massive replay error spew if PCS are enabled.

You can now see the report items saying that PCS aren't supported.

Fixes: #727
  • Loading branch information
ben-clayton committed Aug 31, 2017
1 parent b677a53 commit 4255b6a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
23 changes: 17 additions & 6 deletions gapis/api/gles/stub_program.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ var (
)

func buildStubProgram(ctx context.Context, thread uint64, e *api.CmdExtras, s *api.State, programID ProgramId) []api.Cmd {
vss, fss, err := stubShaderSource(FindProgramInfo(e))
programInfo := FindProgramInfo(e)
vss, fss, err := stubShaderSource(programInfo)
if err != nil {
log.E(ctx, "Unable to build stub shader: %v", err)
}
Expand All @@ -45,9 +46,11 @@ func buildStubProgram(ctx context.Context, thread uint64, e *api.CmdExtras, s *a
return ok || x == uint32(vertexShaderID)
}))
cb := CommandBuilder{Thread: thread}
glLinkProgram := cb.GlLinkProgram(programID)
glLinkProgram.Extras().Add(programInfo)
return append(
CompileProgram(ctx, s, cb, vertexShaderID, fragmentShaderID, programID, vss, fss),
cb.GlLinkProgram(programID),
glLinkProgram,
)
}

Expand Down Expand Up @@ -92,15 +95,23 @@ func stubShaderSource(pi *ProgramInfo) (vertexShaderSource, fragmentShaderSource
sort.Strings(vsTickles)
sort.Strings(fsTickles)
}
return fmt.Sprintf(`// GAPII stub vertex shader
#version 110
return fmt.Sprintf(`#version 150
/////////////////////////////////////////////
// GAPID stub shader (no source available) //
/////////////////////////////////////////////
precision highp float;
%svoid main() {
float no_strip = 0.0;
%sgl_Position = vec4(no_strip * 0.000001, 0., 0., 1.);
}`, strings.Join(vsDecls, ""), strings.Join(vsTickles, "")),
fmt.Sprintf(`// GAPII stub fragment shader
#version 110
fmt.Sprintf(`#version 150
/////////////////////////////////////////////
// GAPID stub shader (no source available) //
/////////////////////////////////////////////
precision highp float;
%svoid main() {
float no_strip = 0.0;
Expand Down
32 changes: 24 additions & 8 deletions gapis/api/gles/stub_program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,25 @@ func TestStubShaderSource(t *testing.T) {
},
},
},
vs: `// GAPII stub vertex shader
#version 110
vs: `#version 150
/////////////////////////////////////////////
// GAPID stub shader (no source available) //
/////////////////////////////////////////////
precision highp float;
uniform vec4 foo;
void main() {
float no_strip = 0.0;
no_strip += foo.x;
gl_Position = vec4(no_strip * 0.000001, 0., 0., 1.);
}`,
fs: `// GAPII stub fragment shader
#version 110
fs: `#version 150
/////////////////////////////////////////////
// GAPID stub shader (no source available) //
/////////////////////////////////////////////
precision highp float;
uniform sampler2D bar;
void main() {
Expand All @@ -74,8 +82,12 @@ void main() {
},
},
},
vs: `// GAPII stub vertex shader
#version 110
vs: `#version 150
/////////////////////////////////////////////
// GAPID stub shader (no source available) //
/////////////////////////////////////////////
precision highp float;
uniform vec4 bar[3];
uniform vec4 foo[3];
Expand All @@ -89,8 +101,12 @@ void main() {
no_strip += foo[2].x;
gl_Position = vec4(no_strip * 0.000001, 0., 0., 1.);
}`,
fs: `// GAPII stub fragment shader
#version 110
fs: `#version 150
/////////////////////////////////////////////
// GAPID stub shader (no source available) //
/////////////////////////////////////////////
precision highp float;
void main() {
float no_strip = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion gapis/replay/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ func (w *adapter) MutateAndWrite(ctx context.Context, id api.CmdID, cmd api.Cmd)
w.builder.CommitCommand()
} else {
w.builder.RevertCommand(err)
log.W(ctx, "Failed to write command %v (%T) for replay: %v", id, cmd, err)
log.W(ctx, "Failed to write command %v %v for replay: %v", id, cmd, err)
}
}

0 comments on commit 4255b6a

Please sign in to comment.