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

Fix undefined framebuffer patterns #1855

Merged
merged 4 commits into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/embed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func run(ctx context.Context) error {
fmt.Fprintf(b, "const %s_file = `%s`\n", entry.name, entry.filename)
fmt.Fprintf(b, "const %s_utf8 = %v\n", entry.name, validUTF8)
fmt.Fprintf(b, "const %s = `%s`\n", entry.name, encoded)
log.I(ctx, "Embed %s from %s\n", entry.name, entry.path)
log.D(ctx, "Embed %s from %s\n", entry.name, entry.path)
}
// reformat the output
result, err := imports.Process("", b.Bytes(), nil)
Expand Down
18 changes: 15 additions & 3 deletions gapis/api/gles/undefined_framebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ func undefinedFramebuffer(ctx context.Context, device *device.Instance) transfor
func drawUndefinedFramebuffer(ctx context.Context, id api.CmdID, cmd api.Cmd, device *device.Instance, s *api.GlobalState, c *Context, out transform.Writer) error {
const (
aScreenCoordsLocation AttributeLocation = 0
aScreenCoords = "aScreenCoords"

vertexShaderSource string = `
#version 100

precision highp float;
attribute vec2 aScreenCoords;
varying vec2 uv;
Expand All @@ -74,6 +77,8 @@ func drawUndefinedFramebuffer(ctx context.Context, id api.CmdID, cmd api.Cmd, de
gl_Position = vec4(aScreenCoords.xy, 0., 1.);
}`
fragmentShaderSource string = `
#version 100

precision highp float;
varying vec2 uv;

Expand Down Expand Up @@ -102,13 +107,20 @@ func drawUndefinedFramebuffer(ctx context.Context, id api.CmdID, cmd api.Cmd, de

programID := t.makeProgram(ctx, vertexShaderSource, fragmentShaderSource)

tmp0 := t.AllocData(ctx, "aScreenCoords")
tmp0 := t.AllocData(ctx, aScreenCoords)
out.MutateAndWrite(ctx, dID, cb.GlBindAttribLocation(programID, aScreenCoordsLocation, tmp0.Ptr()).
AddRead(tmp0.Data()))
tmp0.Free()
out.MutateAndWrite(ctx, dID, api.WithExtras(cb.GlLinkProgram(programID), &LinkProgramExtra{
LinkStatus: GLboolean_GL_TRUE,
ActiveResources: &ActiveProgramResources{},
LinkStatus: GLboolean_GL_TRUE,
ActiveResources: &ActiveProgramResources{
ProgramInputs: NewU32ːProgramResourceʳᵐ().Add(0, &ProgramResource{
Type: GLenum_GL_FLOAT_VEC2,
Name: aScreenCoords,
ArraySize: 1,
Locations: NewU32ːGLintᵐ().Add(0, 0),
}),
},
}))
t.glUseProgram(ctx, programID)

Expand Down
3 changes: 1 addition & 2 deletions gapis/api/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package test
import (
"context"

"github.com/google/gapid/core/image"
"github.com/google/gapid/core/math/interval"
"github.com/google/gapid/gapis/api"
"github.com/google/gapid/gapis/service/path"
Expand All @@ -30,7 +29,7 @@ func (API) GetFramebufferAttachmentInfo(
after []uint64,
state *api.GlobalState,
thread uint64,
attachment api.FramebufferAttachment) (api.FramebufferAttachmentInfo, err error) {
attachment api.FramebufferAttachment) (api.FramebufferAttachmentInfo, error) {
return api.FramebufferAttachmentInfo{}, nil
}

Expand Down
3 changes: 1 addition & 2 deletions gapis/api/testcmd/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/google/gapid/core/data"
"github.com/google/gapid/core/data/deep"
"github.com/google/gapid/core/data/protoconv"
"github.com/google/gapid/core/image"
"github.com/google/gapid/core/os/device"
"github.com/google/gapid/gapil/constset"
"github.com/google/gapid/gapis/api"
Expand Down Expand Up @@ -213,7 +212,7 @@ func (API) GetFramebufferAttachmentInfo(
after []uint64,
state *api.GlobalState,
thread uint64,
attachment api.FramebufferAttachment) (api.FramebufferAttachmentInfo, err error) {
attachment api.FramebufferAttachment) (api.FramebufferAttachmentInfo, error) {
return api.FramebufferAttachmentInfo{}, nil
}
func (API) Context(*api.GlobalState, uint64) api.Context { return nil }
Expand Down
16 changes: 16 additions & 0 deletions test/integration/replay/gles/gles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,22 @@ func TestResizeRenderer(t *testing.T) {
maybeExportCapture(ctx, "resize_renderer", capture)
}

// TestNewContextUndefined checks that a new context is filled with the
// undefined framebuffer pattern.
func TestNewContextUndefined(t *testing.T) {
ctx, f := newFixture(log.Testing(t))

cmds, _, _ := f.initContext(ctx, 64, 64, true)
makeCurrent := api.CmdID(len(cmds) - 1)

intent := replay.Intent{
Capture: f.storeCapture(ctx, cmds),
Device: path.NewDevice(f.device.Instance().Id.ID()),
}

checkColorBuffer(ctx, intent, f.mgr, 64, 64, 0.0, "undef-fb", makeCurrent, nil)
}

// TestPreserveBuffersOnSwap checks that when the preserveBuffersOnSwap flag is
// set, the backbuffer is preserved between calls to eglSwapBuffers().
func TestPreserveBuffersOnSwap(t *testing.T) {
Expand Down
Binary file added test/integration/replay/gles/reference/undef-fb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.