graphicsdriver/opengl: Forbids PBO on Raspberry Pi 4 (#1261)

Fixes #1208
This commit is contained in:
Hajime Hoshi 2020-07-23 19:15:34 +09:00
parent f794fc8d66
commit d2bd8d56c0
4 changed files with 113 additions and 2 deletions

View File

@ -527,11 +527,23 @@ func (c *context) needsRestoring() bool {
} }
func (c *context) canUsePBO() bool { func (c *context) canUsePBO() bool {
return true var available bool
_ = c.t.Call(func() error {
available = isPBOAvailable()
return nil
})
return available
} }
func (c *context) texSubImage2D(t textureNative, width, height int, args []*driver.ReplacePixelsArgs) { func (c *context) texSubImage2D(t textureNative, width, height int, args []*driver.ReplacePixelsArgs) {
panic("opengl: texSubImage2D is not implemented on this environment") c.bindTexture(t)
_ = c.t.Call(func() error {
for _, a := range args {
gl.TexSubImage2D(gl.TEXTURE_2D, 0, int32(a.X), int32(a.Y), int32(a.Width), int32(a.Height), gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(a.Pixels))
}
return nil
})
} }
func (c *context) newPixelBufferObject(width, height int) buffer { func (c *context) newPixelBufferObject(width, height int) buffer {

View File

@ -0,0 +1,21 @@
// Copyright 2020 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build js !freebsd,!linux
package opengl
func isPBOAvailable() bool {
return true
}

View File

@ -0,0 +1,46 @@
// Copyright 2020 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !js
// +build freebsd linux
package opengl
import (
"strings"
"sync"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl/gl"
)
var (
pboAvailable = true
pboAvailableOnce sync.Once
)
func isPBOAvailable() bool {
pboAvailableOnce.Do(func() {
// This must be called after GL context is created.
str := gl.RendererDeviceString()
tokens := strings.Split(str, " ")
if len(tokens) == 0 {
return
}
// Raspbery Pi 4 has an issue around PBO (#1208).
if tokens[0] == "V3D" {
pboAvailable = false
}
})
return pboAvailable
}

View File

@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
// +build !js
// +build freebsd linux
package gl
// #include <GL/glx.h>
//
// static const char* RendererDeviceString() {
// #ifdef GLX_MESA_query_renderer
// static PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC queryString;
// if (!queryString) {
// queryString = (PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC)
// glXGetProcAddressARB((const GLubyte *)"glXQueryCurrentRendererStringMESA");
// }
//
// static const char* rendererDevice;
// if (!rendererDevice) {
// rendererDevice = queryString(GLX_RENDERER_DEVICE_ID_MESA);
// }
//
// return rendererDevice;
// #else
// return "";
// #endif
// }
import "C"
func RendererDeviceString() string {
return C.GoString(C.RendererDeviceString())
}