glshim updated, added latest changes by ptitSeb

This commit is contained in:
lubomyr
2016-03-21 00:39:42 +02:00
parent e5cf2dbd9e
commit b94deb8f97
2 changed files with 41 additions and 20 deletions

View File

@@ -654,8 +654,6 @@ static renderlist_t *arrays_to_renderlist(renderlist_t *list, GLenum mode,
list->tex[i] = copy_gl_pointer_tex(&glstate.vao->pointers.tex_coord[i], 4, skip, count, glstate.vao->pointers.tex_coord[i].buffer); list->tex[i] = copy_gl_pointer_tex(&glstate.vao->pointers.tex_coord[i], 4, skip, count, glstate.vao->pointers.tex_coord[i].buffer);
} }
} }
end_renderlist(list);
return list; return list;
} }
@@ -672,7 +670,7 @@ static inline bool should_intercept_render(GLenum mode) {
} }
void glshim_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { void glshim_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
//printf("glDrawElements(0x%04X, %d, 0x%04X, %p), map=%p\n", mode, count, type, indices, (glstate.buffers.elements)?glstate.buffers.elements->data:NULL); //printf("glDrawElements(0x%04X, %d, 0x%04X, %p), map=%p\n", mode, count, type, indices, (glstate.vao->elements)?glstate.vao->elements->data:NULL);
// TODO: split for count > 65535? // TODO: split for count > 65535?
// special check for QUADS and TRIANGLES that need multiple of 4 or 3 vertex... // special check for QUADS and TRIANGLES that need multiple of 4 or 3 vertex...
if (mode == GL_QUADS) while(count%4) count--; if (mode == GL_QUADS) while(count%4) count--;
@@ -914,6 +912,7 @@ void glshim_glDrawArrays(GLenum mode, GLint first, GLsizei count) {
if (glstate.list.active && (glstate.list.compiling || glstate.gl_batch)) { if (glstate.list.active && (glstate.list.compiling || glstate.gl_batch)) {
NewStage(glstate.list.active, STAGE_DRAW); NewStage(glstate.list.active, STAGE_DRAW);
glstate.list.active = arrays_to_renderlist(glstate.list.active, mode, first, count+first); glstate.list.active = arrays_to_renderlist(glstate.list.active, mode, first, count+first);
end_renderlist(list);
return; return;
} }

View File

@@ -104,6 +104,21 @@ void tex_setup_texcoord(GLuint texunit, GLuint len) {
int nolumalpha = 0; int nolumalpha = 0;
static int is_fake_compressed_rgb(GLenum internalformat)
{
if(internalformat==GL_COMPRESSED_RGB) return 1;
if(internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT) return 1;
return 0;
}
static int is_fake_compressed_rgba(GLenum internalformat)
{
if(internalformat==GL_COMPRESSED_RGBA) return 1;
if(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) return 1;
if(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) return 1;
if(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) return 1;
return 0;
}
static void *swizzle_texture(GLsizei width, GLsizei height, static void *swizzle_texture(GLsizei width, GLsizei height,
GLenum *format, GLenum *type, GLenum *format, GLenum *type,
GLenum intermediaryformat, GLenum internalformat, GLenum intermediaryformat, GLenum internalformat,
@@ -190,10 +205,10 @@ static void *swizzle_texture(GLsizei width, GLsizei height,
break; break;
} }
// compressed format are not handled here, so mask them.... // compressed format are not handled here, so mask them....
if (intermediaryformat==GL_COMPRESSED_RGB) intermediaryformat=GL_RGB; if (is_fake_compressed_rgb(intermediaryformat)) intermediaryformat=GL_RGB;
if (intermediaryformat==GL_COMPRESSED_RGBA) intermediaryformat=GL_RGBA; if (is_fake_compressed_rgba(intermediaryformat)) intermediaryformat=GL_RGBA;
if (internalformat==GL_COMPRESSED_RGB) internalformat=GL_RGB; if (is_fake_compressed_rgb(internalformat)) internalformat=GL_RGB;
if (internalformat==GL_COMPRESSED_RGBA) internalformat=GL_RGBA; if (is_fake_compressed_rgba(internalformat)) internalformat=GL_RGBA;
if(*format != intermediaryformat || intermediaryformat!=internalformat) { if(*format != intermediaryformat || intermediaryformat!=internalformat) {
dest_format = intermediaryformat; dest_format = intermediaryformat;
@@ -332,10 +347,11 @@ GLenum swizzle_internalformat(GLenum *internalformat) {
ret = GL_COMPRESSED_RGB; ret = GL_COMPRESSED_RGB;
sret = GL_RGB; sret = GL_RGB;
break; break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: // not good...
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: // not good, but there is no DXT3 compressor case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: // not good, but there is no DXT3 compressor
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
ret = GL_COMPRESSED_RGBA; ret = GL_COMPRESSED_RGBA;
sret = GL_RGB; sret = GL_RGBA;
break; break;
default: default:
ret = GL_RGBA; ret = GL_RGBA;
@@ -359,6 +375,7 @@ static int default_tex_mipmap = 0;
static int proxy_width = 0; static int proxy_width = 0;
static int proxy_height = 0; static int proxy_height = 0;
static GLint proxy_intformat = 0;
void glshim_glTexImage2D(GLenum target, GLint level, GLint internalformat, void glshim_glTexImage2D(GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLint border, GLsizei width, GLsizei height, GLint border,
@@ -369,6 +386,7 @@ void glshim_glTexImage2D(GLenum target, GLint level, GLint internalformat,
if (target == GL_PROXY_TEXTURE_2D) { if (target == GL_PROXY_TEXTURE_2D) {
proxy_width = ((width<<level)>(texshrink==8)?8192:2048)?0:width; proxy_width = ((width<<level)>(texshrink==8)?8192:2048)?0:width;
proxy_height = ((height<<level)>(texshrink==8)?8192:2048)?0:height; proxy_height = ((height<<level)>(texshrink==8)?8192:2048)?0:height;
proxy_intformat = swizzle_internalformat(&internalformat);
return; return;
} }
//PUSH_IF_COMPILING(glTexImage2D); //PUSH_IF_COMPILING(glTexImage2D);
@@ -399,7 +417,7 @@ void glshim_glTexImage2D(GLenum target, GLint level, GLint internalformat,
bound->mipmap_need = 1; bound->mipmap_need = 1;
} }
GLenum new_format = swizzle_internalformat(&internalformat); GLenum new_format = swizzle_internalformat(&internalformat);
if (bound) { if (bound && (level==0)) {
bound->orig_internal = internalformat; bound->orig_internal = internalformat;
bound->internalformat = new_format; bound->internalformat = new_format;
} }
@@ -821,7 +839,7 @@ void glshim_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yof
pixels = (GLvoid *)dst; pixels = (GLvoid *)dst;
const GLubyte *src = (GLubyte *)datab; const GLubyte *src = (GLubyte *)datab;
src += glstate.texture.unpack_skip_pixels * pixelSize + glstate.texture.unpack_skip_rows * imgWidth; src += glstate.texture.unpack_skip_pixels * pixelSize + glstate.texture.unpack_skip_rows * imgWidth;
for (int y = 0; y < height; y += 1) { for (int y = 0; y < height; y ++) {
memcpy(dst, src, width * pixelSize); memcpy(dst, src, width * pixelSize);
src += imgWidth; src += imgWidth;
dst += width * pixelSize; dst += width * pixelSize;
@@ -1369,16 +1387,20 @@ void glshim_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, G
} }
break; break;
case GL_TEXTURE_INTERNAL_FORMAT: case GL_TEXTURE_INTERNAL_FORMAT:
if (bound && bound->compressed) if (target==GL_PROXY_TEXTURE_2D)
(*params) = bound->format; (*params) = proxy_intformat;
else { else {
if(bound && ((bound->orig_internal==GL_COMPRESSED_RGB) || (bound->orig_internal==GL_COMPRESSED_RGBA))) { if (bound && bound->compressed)
if(bound->orig_internal==GL_COMPRESSED_RGB) (*params) = bound->format;
*(params) = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; else {
else if(bound && ((bound->orig_internal==GL_COMPRESSED_RGB) || (bound->orig_internal==GL_COMPRESSED_RGBA))) {
*(params) = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; if(bound->orig_internal==GL_COMPRESSED_RGB)
} else *(params) = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
(*params) = GL_RGBA; else
*(params) = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
} else
(*params) = GL_RGBA;
}
} }
break; break;
case GL_TEXTURE_DEPTH: case GL_TEXTURE_DEPTH: