Skip to content

Commit

Permalink
Remove the SharedObjects indirection container.
Browse files Browse the repository at this point in the history
The container was just a hack around the fact we could not
share pointer to the same map from two different contexts.
Since that is possible now, clean up by removing the hack.
  • Loading branch information
dsrbecky committed Nov 1, 2017
1 parent 4cba0a6 commit 128e0d8
Show file tree
Hide file tree
Showing 20 changed files with 204 additions and 224 deletions.
20 changes: 10 additions & 10 deletions gapis/api/gles/api/buffer_objects.api
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ sub ref!Buffer GetBoundBufferAtIndex(GLenum target, GLuint index) {

sub ref!Buffer GetOrCreateBuffer(BufferId id) {
ctx := GetContext()
if (id != 0) && (ctx.Objects.Shared.Buffers[id] == null) {
ctx.Objects.Shared.Buffers[id] = new!Buffer(ID: id)
ctx.Objects.Shared.GeneratedNames.Buffers[id] = true
if (id != 0) && (ctx.Objects.Buffers[id] == null) {
ctx.Objects.Buffers[id] = new!Buffer(ID: id)
ctx.Objects.GeneratedNames.Buffers[id] = true
}
return ctx.Objects.Shared.Buffers[id]
return ctx.Objects.Buffers[id]
}

@if(Version.GLES10)
Expand Down Expand Up @@ -190,8 +190,8 @@ cmd void glBindBuffer(GLenum target, BufferId buffer) {
@doc("https://www.khronos.org/opengles/sdk/docs/man32/html/glBindBufferBase.xhtml", Version.GLES32)
cmd void glBindBufferBase(GLenum target, GLuint index, BufferId buffer) {
ctx := GetContext()
size := switch (buffer in ctx.Objects.Shared.Buffers) {
case true: ctx.Objects.Shared.Buffers[buffer].Size
size := switch (buffer in ctx.Objects.Buffers) {
case true: ctx.Objects.Buffers[buffer].Size
case false: as!GLsizeiptr(0)
}
BindBufferRange(target, index, buffer, 0, size)
Expand Down Expand Up @@ -320,8 +320,8 @@ cmd void glDeleteBuffers(GLsizei count, const BufferId* buffers) {
for i in (0 .. count) {
id := b[i]
if id != 0 {
delete(ctx.Objects.Shared.Buffers, id)
delete(ctx.Objects.Shared.GeneratedNames.Buffers, id)
delete(ctx.Objects.Buffers, id)
delete(ctx.Objects.GeneratedNames.Buffers, id)
}
}
}
Expand All @@ -338,7 +338,7 @@ cmd void glGenBuffers(GLsizei count, BufferId* buffers) {
for i in (0 .. count) {
id := as!BufferId(?)
assert(id != 0)
ctx.Objects.Shared.GeneratedNames.Buffers[id] = true
ctx.Objects.GeneratedNames.Buffers[id] = true
b[i] = id
}
}
Expand Down Expand Up @@ -437,7 +437,7 @@ sub void GetBufferPointerv(GLenum target, GLenum pname, void** params) {
cmd GLboolean glIsBuffer(BufferId buffer) {

ctx := GetContext()
return as!GLboolean(buffer in ctx.Objects.Shared.Buffers)
return as!GLboolean(buffer in ctx.Objects.Buffers)
}

// This command only exits in desktop GL - but we need the signature in compat.
Expand Down
24 changes: 12 additions & 12 deletions gapis/api/gles/api/debug.api
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ sub void ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLcha
ctx := GetContext()
switch (identifier) {
case GL_TEXTURE: {
if !(as!TextureId(name) in ctx.Objects.Shared.Textures) {
if !(as!TextureId(name) in ctx.Objects.Textures) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(name)
}
ctx.Objects.Shared.Textures[as!TextureId(name)].Label = str
ctx.Objects.Textures[as!TextureId(name)].Label = str
}
case GL_FRAMEBUFFER: {
if !(as!FramebufferId(name) in ctx.Objects.Framebuffers) {
Expand All @@ -254,28 +254,28 @@ sub void ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLcha
ctx.Objects.Framebuffers[as!FramebufferId(name)].Label = str
}
case GL_RENDERBUFFER: {
if !(as!RenderbufferId(name) in ctx.Objects.Shared.Renderbuffers) {
if !(as!RenderbufferId(name) in ctx.Objects.Renderbuffers) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(name)
}
ctx.Objects.Shared.Renderbuffers[as!RenderbufferId(name)].Label = str
ctx.Objects.Renderbuffers[as!RenderbufferId(name)].Label = str
}
case GL_BUFFER: {
if !(as!BufferId(name) in ctx.Objects.Shared.Buffers) {
if !(as!BufferId(name) in ctx.Objects.Buffers) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(name)
}
ctx.Objects.Shared.Buffers[as!BufferId(name)].Label = str
ctx.Objects.Buffers[as!BufferId(name)].Label = str
}
case GL_SHADER: {
if !(as!ShaderId(name) in ctx.Objects.Shared.Shaders) {
if !(as!ShaderId(name) in ctx.Objects.Shaders) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(name)
}
ctx.Objects.Shared.Shaders[as!ShaderId(name)].Label = str
ctx.Objects.Shaders[as!ShaderId(name)].Label = str
}
case GL_PROGRAM: {
if !(as!ProgramId(name) in ctx.Objects.Shared.Programs) {
if !(as!ProgramId(name) in ctx.Objects.Programs) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(name)
}
ctx.Objects.Shared.Programs[as!ProgramId(name)].Label = str
ctx.Objects.Programs[as!ProgramId(name)].Label = str
}
case GL_VERTEX_ARRAY: {
if !(as!VertexArrayId(name) in ctx.Objects.VertexArrays) {
Expand All @@ -290,10 +290,10 @@ sub void ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLcha
ctx.Objects.Queries[as!QueryId(name)].Label = str
}
case GL_SAMPLER: {
if !(as!SamplerId(name) in ctx.Objects.Shared.Samplers) {
if !(as!SamplerId(name) in ctx.Objects.Samplers) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(name)
}
ctx.Objects.Shared.Samplers[as!SamplerId(name)].Label = str
ctx.Objects.Samplers[as!SamplerId(name)].Label = str
}
case GL_TRANSFORM_FEEDBACK: {
if !(as!TransformFeedbackId(name) in ctx.Objects.TransformFeedbacks) {
Expand Down
2 changes: 1 addition & 1 deletion gapis/api/gles/api/egl.api
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ cmd EGLImageKHR eglCreateImageKHR(EGLDisplay dpy,
case EGL_GL_TEXTURE_2D: {
c := EGLContexts[ctx]
assert(c != null) // EGL_BAD_CONTEXT
t := c.Objects.Shared.Textures[as!TextureId(as!u64(buffer))]
t := c.Objects.Textures[as!TextureId(as!u64(buffer))]
assert(t != null) // EGL_BAD_PARAMETER
i := t.Levels[0].Layers[0]
assert(i != null) // EGL_BAD_PARAMETER
Expand Down
28 changes: 14 additions & 14 deletions gapis/api/gles/api/extensions.api
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,9 @@ sub void FramebufferTextureMultiviewOVR(GLenum target,
ctx := GetContext()
attachment_info := FramebufferAttachment()
if (texture != 0) {
if !(texture in ctx.Objects.Shared.Textures) { glErrorInvalidObjectName!TextureId(texture) }
if !(texture in ctx.Objects.Textures) { glErrorInvalidObjectName!TextureId(texture) }
attachment_info.Type = GL_TEXTURE
attachment_info.Texture = ctx.Objects.Shared.Textures[texture]
attachment_info.Texture = ctx.Objects.Textures[texture]
attachment_info.TextureLevel = level
attachment_info.TextureLayer = baseViewIndex
attachment_info.NumViews = numViews
Expand Down Expand Up @@ -1540,10 +1540,10 @@ cmd void glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLch
ctx := GetContext()
switch (type) {
case GL_TEXTURE: {
if !(as!TextureId(object) in ctx.Objects.Shared.Textures) {
if !(as!TextureId(object) in ctx.Objects.Textures) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(object)
}
ctx.Objects.Shared.Textures[as!TextureId(object)].Label = str
ctx.Objects.Textures[as!TextureId(object)].Label = str
}
case GL_FRAMEBUFFER: {
if !(as!FramebufferId(object) in ctx.Objects.Framebuffers) {
Expand All @@ -1552,28 +1552,28 @@ cmd void glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLch
ctx.Objects.Framebuffers[as!FramebufferId(object)].Label = str
}
case GL_RENDERBUFFER: {
if !(as!RenderbufferId(object) in ctx.Objects.Shared.Renderbuffers) {
if !(as!RenderbufferId(object) in ctx.Objects.Renderbuffers) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(object)
}
ctx.Objects.Shared.Renderbuffers[as!RenderbufferId(object)].Label = str
ctx.Objects.Renderbuffers[as!RenderbufferId(object)].Label = str
}
case GL_BUFFER_OBJECT_EXT: {
if !(as!BufferId(object) in ctx.Objects.Shared.Buffers) {
if !(as!BufferId(object) in ctx.Objects.Buffers) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(object)
}
ctx.Objects.Shared.Buffers[as!BufferId(object)].Label = str
ctx.Objects.Buffers[as!BufferId(object)].Label = str
}
case GL_SHADER_OBJECT_EXT: {
if !(as!ShaderId(object) in ctx.Objects.Shared.Shaders) {
if !(as!ShaderId(object) in ctx.Objects.Shaders) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(object)
}
ctx.Objects.Shared.Shaders[as!ShaderId(object)].Label = str
ctx.Objects.Shaders[as!ShaderId(object)].Label = str
}
case GL_PROGRAM_OBJECT_EXT: {
if !(as!ProgramId(object) in ctx.Objects.Shared.Programs) {
if !(as!ProgramId(object) in ctx.Objects.Programs) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(object)
}
ctx.Objects.Shared.Programs[as!ProgramId(object)].Label = str
ctx.Objects.Programs[as!ProgramId(object)].Label = str
}
case GL_VERTEX_ARRAY_OBJECT_EXT: {
if !(as!VertexArrayId(object) in ctx.Objects.VertexArrays) {
Expand All @@ -1588,10 +1588,10 @@ cmd void glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLch
ctx.Objects.Queries[as!QueryId(object)].Label = str
}
case GL_SAMPLER: {
if !(as!SamplerId(object) in ctx.Objects.Shared.Samplers) {
if !(as!SamplerId(object) in ctx.Objects.Samplers) {
glErrorInvalidOperation_ObjectDoesNotExist!GLuint(object)
}
ctx.Objects.Shared.Samplers[as!SamplerId(object)].Label = str
ctx.Objects.Samplers[as!SamplerId(object)].Label = str
}
case GL_TRANSFORM_FEEDBACK: {
if !(as!TransformFeedbackId(object) in ctx.Objects.TransformFeedbacks) {
Expand Down
4 changes: 2 additions & 2 deletions gapis/api/gles/api/extras.api
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern ref!ProgramInfo GetProgramInfoExtra(ref!Context ctx, ProgramId programId)
sub void ApplyProgramInfoExtra(ProgramId programId, ref!ProgramInfo info) {
if (info != null) {
ctx := GetContext()
program := ctx.Objects.Shared.Programs[programId]
program := ctx.Objects.Programs[programId]
program.LinkStatus = info.LinkStatus
program.InfoLog = info.InfoLog
program.ActiveAttributes = null
Expand Down Expand Up @@ -251,4 +251,4 @@ sub GLenum hintAtAttributeType(GLenum ty) {
default:
ty
}
}
}
34 changes: 17 additions & 17 deletions gapis/api/gles/api/framebuffer.api
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ cmd void glBindRenderbuffer(GLenum target, RenderbufferId renderbuffer) {

sub ref!Renderbuffer GetOrCreateRenderbuffer(RenderbufferId id) {
ctx := GetContext()
if (id != 0) && (ctx.Objects.Shared.Renderbuffers[id] == null) {
ctx.Objects.Shared.Renderbuffers[id] = new!Renderbuffer(ID: id)
ctx.Objects.Shared.GeneratedNames.Renderbuffers[id] = true
if (id != 0) && (ctx.Objects.Renderbuffers[id] == null) {
ctx.Objects.Renderbuffers[id] = new!Renderbuffer(ID: id)
ctx.Objects.GeneratedNames.Renderbuffers[id] = true
}
return ctx.Objects.Shared.Renderbuffers[id]
return ctx.Objects.Renderbuffers[id]
}

@if(Version.GLES30)
Expand Down Expand Up @@ -493,8 +493,8 @@ cmd void glDeleteRenderbuffers(GLsizei count, const RenderbufferId* renderbuffer
for i in (0 .. count) {
id := r[i]
if id != 0 {
delete(ctx.Objects.Shared.Renderbuffers, id)
delete(ctx.Objects.Shared.GeneratedNames.Renderbuffers, id)
delete(ctx.Objects.Renderbuffers, id)
delete(ctx.Objects.GeneratedNames.Renderbuffers, id)
}
}
}
Expand Down Expand Up @@ -571,14 +571,14 @@ cmd void glFramebufferRenderbuffer(GLenum framebuffer_target,
ctx := GetContext()
if renderbuffer_target != GL_RENDERBUFFER { glErrorInvalidEnum(renderbuffer_target) }
// SPEC: Only PDF spec mentions this:
if (renderbuffer != 0) && !(renderbuffer in ctx.Objects.Shared.Renderbuffers) {
if (renderbuffer != 0) && !(renderbuffer in ctx.Objects.Renderbuffers) {
glErrorInvalidOperation_ObjectDoesNotExist!RenderbufferId(renderbuffer)
}

attachment := FramebufferAttachment()
if (renderbuffer != 0) {
attachment.Type = GL_RENDERBUFFER
attachment.Renderbuffer = ctx.Objects.Shared.Renderbuffers[renderbuffer]
attachment.Renderbuffer = ctx.Objects.Renderbuffers[renderbuffer]
}
SetFramebufferAttachment(framebuffer_target, framebuffer_attachment, attachment)
}
Expand All @@ -593,9 +593,9 @@ sub void FramebufferTexture(GLenum target, GLenum attachment, TextureId texture,
ctx := GetContext()
attachment_info := FramebufferAttachment()
if (texture != 0) {
if !(texture in ctx.Objects.Shared.Textures) { glErrorInvalidValue!TextureId(texture) }
if !(texture in ctx.Objects.Textures) { glErrorInvalidValue!TextureId(texture) }
attachment_info.Type = GL_TEXTURE
attachment_info.Texture = ctx.Objects.Shared.Textures[texture]
attachment_info.Texture = ctx.Objects.Textures[texture]
attachment_info.TextureLevel = level
attachment_info.Layered = 0 // TODO
}
Expand Down Expand Up @@ -639,7 +639,7 @@ sub void FramebufferTexture2D(GLenum framebuffer_target,
ctx := GetContext()
attachment := FramebufferAttachment()
if (texture != 0) {
if !(texture in ctx.Objects.Shared.Textures) {
if !(texture in ctx.Objects.Textures) {
glErrorInvalidOperation_ObjectDoesNotExist!TextureId(texture)
}
kind := switch (texture_target) {
Expand All @@ -655,9 +655,9 @@ sub void FramebufferTexture2D(GLenum framebuffer_target,
as!GLenum(0)
}
// TODO: Handle texture 0
if ctx.Objects.Shared.Textures[texture].Kind != kind { glErrorInvalidOperation() }
if ctx.Objects.Textures[texture].Kind != kind { glErrorInvalidOperation() }
attachment.Type = GL_TEXTURE
attachment.Texture = ctx.Objects.Shared.Textures[texture]
attachment.Texture = ctx.Objects.Textures[texture]
attachment.TextureLevel = level
attachment.TextureLayer = CubemapFaceToLayer(texture_target)
}
Expand All @@ -676,9 +676,9 @@ cmd void glFramebufferTextureLayer(GLenum target,
ctx := GetContext()
attachment_info := FramebufferAttachment()
if (texture != 0) {
if !(texture in ctx.Objects.Shared.Textures) { glErrorInvalidValue!TextureId(texture) }
if !(texture in ctx.Objects.Textures) { glErrorInvalidValue!TextureId(texture) }
attachment_info.Type = GL_TEXTURE
attachment_info.Texture = ctx.Objects.Shared.Textures[texture]
attachment_info.Texture = ctx.Objects.Textures[texture]
attachment_info.TextureLevel = level
attachment_info.TextureLayer = layer
}
Expand Down Expand Up @@ -714,7 +714,7 @@ cmd void glGenRenderbuffers(GLsizei count, RenderbufferId* renderbuffers) {
for i in (0 .. count) {
id := as!RenderbufferId(?)
assert(id != 0)
ctx.Objects.Shared.GeneratedNames.Renderbuffers[id] = true
ctx.Objects.GeneratedNames.Renderbuffers[id] = true
r[i] = id
}
}
Expand Down Expand Up @@ -935,7 +935,7 @@ cmd GLboolean glIsFramebuffer(FramebufferId framebuffer) {
cmd GLboolean glIsRenderbuffer(RenderbufferId renderbuffer) {

ctx := GetContext()
return as!GLboolean(renderbuffer in ctx.Objects.Shared.Renderbuffers)
return as!GLboolean(renderbuffer in ctx.Objects.Renderbuffers)
}

@if(Version.GLES30)
Expand Down
Loading

0 comments on commit 128e0d8

Please sign in to comment.