Skip to content

Commit

Permalink
gl: enable use of buffer objects for TexSubImage2D by nil
Browse files Browse the repository at this point in the history
This CL enables use of a bound buffer at TexSubImage2D by allowing
nil (0) data, which indicates the head of the bound buffer.

In the long run, we need to be able to pass non-0 integer to not
only TexSubImage2D but also other functions like TexImage2D. As we
might change the API, let's revisit this issue later.

Fixes golang/go#36355

Change-Id: I66f6650b10fca9a346cfa6eba246ea9286ed3a85
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/213077
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
hajimehoshi committed Jan 19, 2020
1 parent d70acc1 commit 0c13fd3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gl/gl.go
Expand Up @@ -1284,6 +1284,14 @@ func (ctx *context) TexImage2D(target Enum, level int, internalFormat int, width
}

func (ctx *context) TexSubImage2D(target Enum, level int, x, y, width, height int, format, ty Enum, data []byte) {
// It is common to pass TexSubImage2D a nil data, indicating that a
// bound GL buffer is being used as the source. In that case, it
// is not necessary to block.
parg := unsafe.Pointer(nil)
if len(data) > 0 {
parg = unsafe.Pointer(&data[0])
}

ctx.enqueue(call{
args: fnargs{
fn: glfnTexSubImage2D,
Expand All @@ -1297,8 +1305,8 @@ func (ctx *context) TexSubImage2D(target Enum, level int, x, y, width, height in
a6: format.c(),
a7: ty.c(),
},
parg: unsafe.Pointer(&data[0]),
blocking: true,
parg: parg,
blocking: parg != nil,
})
}

Expand Down

0 comments on commit 0c13fd3

Please sign in to comment.