internal/graphicsdriver/opengl: remove IsFramebuffer and IsRenderbuffer

These function return true in most cases, and when these return false,
the situation is pretty bad and recovering the situation would not be
possible.

IsFramebuffer and IsRenderbuffer cause round trips and affect performance.
Let's remove them.
This commit is contained in:
Hajime Hoshi 2024-07-06 19:10:03 +09:00
parent 1db031a9d7
commit 073d022c2e
6 changed files with 0 additions and 74 deletions

View File

@ -320,9 +320,6 @@ func (c *context) newRenderbuffer(width, height int) (renderbufferNative, error)
} }
func (c *context) deleteRenderbuffer(r renderbufferNative) { func (c *context) deleteRenderbuffer(r renderbufferNative) {
if !c.ctx.IsRenderbuffer(uint32(r)) {
return
}
if c.lastRenderbuffer == r { if c.lastRenderbuffer == r {
c.lastRenderbuffer = 0 c.lastRenderbuffer = 0
} }
@ -375,9 +372,6 @@ func (c *context) deleteFramebuffer(f framebufferNative) {
if f == c.screenFramebuffer { if f == c.screenFramebuffer {
return return
} }
if !c.ctx.IsFramebuffer(uint32(f)) {
return
}
// If a framebuffer to be deleted is bound, a newly bound framebuffer // If a framebuffer to be deleted is bound, a newly bound framebuffer
// will be a default framebuffer. // will be a default framebuffer.
// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml

View File

@ -406,15 +406,6 @@ func (d *DebugContext) IsES() bool {
return out0 return out0
} }
func (d *DebugContext) IsFramebuffer(arg0 uint32) bool {
out0 := d.Context.IsFramebuffer(arg0)
fmt.Fprintln(os.Stderr, "IsFramebuffer")
if e := d.Context.GetError(); e != NO_ERROR {
panic(fmt.Sprintf("gl: GetError() returned %d at IsFramebuffer", e))
}
return out0
}
func (d *DebugContext) IsProgram(arg0 uint32) bool { func (d *DebugContext) IsProgram(arg0 uint32) bool {
out0 := d.Context.IsProgram(arg0) out0 := d.Context.IsProgram(arg0)
fmt.Fprintln(os.Stderr, "IsProgram") fmt.Fprintln(os.Stderr, "IsProgram")
@ -424,15 +415,6 @@ func (d *DebugContext) IsProgram(arg0 uint32) bool {
return out0 return out0
} }
func (d *DebugContext) IsRenderbuffer(arg0 uint32) bool {
out0 := d.Context.IsRenderbuffer(arg0)
fmt.Fprintln(os.Stderr, "IsRenderbuffer")
if e := d.Context.GetError(); e != NO_ERROR {
panic(fmt.Sprintf("gl: GetError() returned %d at IsRenderbuffer", e))
}
return out0
}
func (d *DebugContext) LinkProgram(arg0 uint32) { func (d *DebugContext) LinkProgram(arg0 uint32) {
d.Context.LinkProgram(arg0) d.Context.LinkProgram(arg0)
fmt.Fprintln(os.Stderr, "LinkProgram") fmt.Fprintln(os.Stderr, "LinkProgram")

View File

@ -200,18 +200,10 @@ package gl
// typedef GLint (*fn)(GLuint program, const GLchar* name); // typedef GLint (*fn)(GLuint program, const GLchar* name);
// return ((fn)(fnptr))(program, name); // return ((fn)(fnptr))(program, name);
// } // }
// static GLboolean glowIsFramebuffer(uintptr_t fnptr, GLuint framebuffer) {
// typedef GLboolean (*fn)(GLuint framebuffer);
// return ((fn)(fnptr))(framebuffer);
// }
// static GLboolean glowIsProgram(uintptr_t fnptr, GLuint program) { // static GLboolean glowIsProgram(uintptr_t fnptr, GLuint program) {
// typedef GLboolean (*fn)(GLuint program); // typedef GLboolean (*fn)(GLuint program);
// return ((fn)(fnptr))(program); // return ((fn)(fnptr))(program);
// } // }
// static GLboolean glowIsRenderbuffer(uintptr_t fnptr, GLuint renderbuffer) {
// typedef GLboolean (*fn)(GLuint renderbuffer);
// return ((fn)(fnptr))(renderbuffer);
// }
// static void glowLinkProgram(uintptr_t fnptr, GLuint program) { // static void glowLinkProgram(uintptr_t fnptr, GLuint program) {
// typedef void (*fn)(GLuint program); // typedef void (*fn)(GLuint program);
// ((fn)(fnptr))(program); // ((fn)(fnptr))(program);
@ -369,9 +361,7 @@ type defaultContext struct {
gpGetShaderInfoLog C.uintptr_t gpGetShaderInfoLog C.uintptr_t
gpGetShaderiv C.uintptr_t gpGetShaderiv C.uintptr_t
gpGetUniformLocation C.uintptr_t gpGetUniformLocation C.uintptr_t
gpIsFramebuffer C.uintptr_t
gpIsProgram C.uintptr_t gpIsProgram C.uintptr_t
gpIsRenderbuffer C.uintptr_t
gpLinkProgram C.uintptr_t gpLinkProgram C.uintptr_t
gpPixelStorei C.uintptr_t gpPixelStorei C.uintptr_t
gpReadPixels C.uintptr_t gpReadPixels C.uintptr_t
@ -633,21 +623,11 @@ func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
return int32(ret) return int32(ret)
} }
func (c *defaultContext) IsFramebuffer(framebuffer uint32) bool {
ret := C.glowIsFramebuffer(c.gpIsFramebuffer, C.GLuint(framebuffer))
return ret == TRUE
}
func (c *defaultContext) IsProgram(program uint32) bool { func (c *defaultContext) IsProgram(program uint32) bool {
ret := C.glowIsProgram(c.gpIsProgram, C.GLuint(program)) ret := C.glowIsProgram(c.gpIsProgram, C.GLuint(program))
return ret == TRUE return ret == TRUE
} }
func (c *defaultContext) IsRenderbuffer(renderbuffer uint32) bool {
ret := C.glowIsRenderbuffer(c.gpIsRenderbuffer, C.GLuint(renderbuffer))
return ret == TRUE
}
func (c *defaultContext) LinkProgram(program uint32) { func (c *defaultContext) LinkProgram(program uint32) {
C.glowLinkProgram(c.gpLinkProgram, C.GLuint(program)) C.glowLinkProgram(c.gpLinkProgram, C.GLuint(program))
} }
@ -819,9 +799,7 @@ func (c *defaultContext) LoadFunctions() error {
c.gpGetShaderInfoLog = C.uintptr_t(g.get("glGetShaderInfoLog")) c.gpGetShaderInfoLog = C.uintptr_t(g.get("glGetShaderInfoLog"))
c.gpGetShaderiv = C.uintptr_t(g.get("glGetShaderiv")) c.gpGetShaderiv = C.uintptr_t(g.get("glGetShaderiv"))
c.gpGetUniformLocation = C.uintptr_t(g.get("glGetUniformLocation")) c.gpGetUniformLocation = C.uintptr_t(g.get("glGetUniformLocation"))
c.gpIsFramebuffer = C.uintptr_t(g.get("glIsFramebuffer"))
c.gpIsProgram = C.uintptr_t(g.get("glIsProgram")) c.gpIsProgram = C.uintptr_t(g.get("glIsProgram"))
c.gpIsRenderbuffer = C.uintptr_t(g.get("glIsRenderbuffer"))
c.gpLinkProgram = C.uintptr_t(g.get("glLinkProgram")) c.gpLinkProgram = C.uintptr_t(g.get("glLinkProgram"))
c.gpPixelStorei = C.uintptr_t(g.get("glPixelStorei")) c.gpPixelStorei = C.uintptr_t(g.get("glPixelStorei"))
c.gpReadPixels = C.uintptr_t(g.get("glReadPixels")) c.gpReadPixels = C.uintptr_t(g.get("glReadPixels"))

View File

@ -67,9 +67,7 @@ type defaultContext struct {
fnGetShaderInfoLog js.Value fnGetShaderInfoLog js.Value
fnGetShaderParameter js.Value fnGetShaderParameter js.Value
fnGetUniformLocation js.Value fnGetUniformLocation js.Value
fnIsFramebuffer js.Value
fnIsProgram js.Value fnIsProgram js.Value
fnIsRenderbuffer js.Value
fnLinkProgram js.Value fnLinkProgram js.Value
fnPixelStorei js.Value fnPixelStorei js.Value
fnReadPixels js.Value fnReadPixels js.Value
@ -197,9 +195,7 @@ func NewDefaultContext(v js.Value) (Context, error) {
fnGetShaderInfoLog: v.Get("getShaderInfoLog").Call("bind", v), fnGetShaderInfoLog: v.Get("getShaderInfoLog").Call("bind", v),
fnGetShaderParameter: v.Get("getShaderParameter").Call("bind", v), fnGetShaderParameter: v.Get("getShaderParameter").Call("bind", v),
fnGetUniformLocation: v.Get("getUniformLocation").Call("bind", v), fnGetUniformLocation: v.Get("getUniformLocation").Call("bind", v),
fnIsFramebuffer: v.Get("isFramebuffer").Call("bind", v),
fnIsProgram: v.Get("isProgram").Call("bind", v), fnIsProgram: v.Get("isProgram").Call("bind", v),
fnIsRenderbuffer: v.Get("isRenderbuffer").Call("bind", v),
fnLinkProgram: v.Get("linkProgram").Call("bind", v), fnLinkProgram: v.Get("linkProgram").Call("bind", v),
fnPixelStorei: v.Get("pixelStorei").Call("bind", v), fnPixelStorei: v.Get("pixelStorei").Call("bind", v),
fnReadPixels: v.Get("readPixels").Call("bind", v), fnReadPixels: v.Get("readPixels").Call("bind", v),
@ -481,18 +477,10 @@ func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
return int32((program << 5) | idx) return int32((program << 5) | idx)
} }
func (c *defaultContext) IsFramebuffer(framebuffer uint32) bool {
return c.fnIsFramebuffer.Invoke(c.framebuffers.get(framebuffer)).Bool()
}
func (c *defaultContext) IsProgram(program uint32) bool { func (c *defaultContext) IsProgram(program uint32) bool {
return c.fnIsProgram.Invoke(c.programs.get(program)).Bool() return c.fnIsProgram.Invoke(c.programs.get(program)).Bool()
} }
func (c *defaultContext) IsRenderbuffer(renderbuffer uint32) bool {
return c.fnIsRenderbuffer.Invoke(c.renderbuffers.get(renderbuffer)).Bool()
}
func (c *defaultContext) LinkProgram(program uint32) { func (c *defaultContext) LinkProgram(program uint32) {
c.fnLinkProgram.Invoke(c.programs.get(program)) c.fnLinkProgram.Invoke(c.programs.get(program))
} }

View File

@ -69,9 +69,7 @@ type defaultContext struct {
gpGetShaderInfoLog uintptr gpGetShaderInfoLog uintptr
gpGetShaderiv uintptr gpGetShaderiv uintptr
gpGetUniformLocation uintptr gpGetUniformLocation uintptr
gpIsFramebuffer uintptr
gpIsProgram uintptr gpIsProgram uintptr
gpIsRenderbuffer uintptr
gpLinkProgram uintptr gpLinkProgram uintptr
gpPixelStorei uintptr gpPixelStorei uintptr
gpReadPixels uintptr gpReadPixels uintptr
@ -333,21 +331,11 @@ func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
return int32(ret) return int32(ret)
} }
func (c *defaultContext) IsFramebuffer(framebuffer uint32) bool {
ret, _, _ := purego.SyscallN(c.gpIsFramebuffer, uintptr(framebuffer))
return byte(ret) != 0
}
func (c *defaultContext) IsProgram(program uint32) bool { func (c *defaultContext) IsProgram(program uint32) bool {
ret, _, _ := purego.SyscallN(c.gpIsProgram, uintptr(program)) ret, _, _ := purego.SyscallN(c.gpIsProgram, uintptr(program))
return byte(ret) != 0 return byte(ret) != 0
} }
func (c *defaultContext) IsRenderbuffer(renderbuffer uint32) bool {
ret, _, _ := purego.SyscallN(c.gpIsRenderbuffer, uintptr(renderbuffer))
return byte(ret) != 0
}
func (c *defaultContext) LinkProgram(program uint32) { func (c *defaultContext) LinkProgram(program uint32) {
purego.SyscallN(c.gpLinkProgram, uintptr(program)) purego.SyscallN(c.gpLinkProgram, uintptr(program))
} }
@ -519,9 +507,7 @@ func (c *defaultContext) LoadFunctions() error {
c.gpGetShaderInfoLog = g.get("glGetShaderInfoLog") c.gpGetShaderInfoLog = g.get("glGetShaderInfoLog")
c.gpGetShaderiv = g.get("glGetShaderiv") c.gpGetShaderiv = g.get("glGetShaderiv")
c.gpGetUniformLocation = g.get("glGetUniformLocation") c.gpGetUniformLocation = g.get("glGetUniformLocation")
c.gpIsFramebuffer = g.get("glIsFramebuffer")
c.gpIsProgram = g.get("glIsProgram") c.gpIsProgram = g.get("glIsProgram")
c.gpIsRenderbuffer = g.get("glIsRenderbuffer")
c.gpLinkProgram = g.get("glLinkProgram") c.gpLinkProgram = g.get("glLinkProgram")
c.gpPixelStorei = g.get("glPixelStorei") c.gpPixelStorei = g.get("glPixelStorei")
c.gpReadPixels = g.get("glReadPixels") c.gpReadPixels = g.get("glReadPixels")

View File

@ -72,9 +72,7 @@ type Context interface {
GetShaderInfoLog(shader uint32) string GetShaderInfoLog(shader uint32) string
GetShaderi(shader uint32, pname uint32) int GetShaderi(shader uint32, pname uint32) int
GetUniformLocation(program uint32, name string) int32 GetUniformLocation(program uint32, name string) int32
IsFramebuffer(framebuffer uint32) bool
IsProgram(program uint32) bool IsProgram(program uint32) bool
IsRenderbuffer(renderbuffer uint32) bool
LinkProgram(program uint32) LinkProgram(program uint32)
PixelStorei(pname uint32, param int32) PixelStorei(pname uint32, param int32)
ReadPixels(dst []byte, x int32, y int32, width int32, height int32, format uint32, xtype uint32) ReadPixels(dst []byte, x int32, y int32, width int32, height int32, format uint32, xtype uint32)