mirror of https://github.com/xemu-project/xemu.git
cleanups to context creation; handle 0 viewport z scale
This commit is contained in:
parent
ca76432648
commit
7116f4eb13
|
@ -25,6 +25,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "qemu-common.h"
|
||||||
|
|
||||||
#include <OpenGL/gl.h>
|
#include <OpenGL/gl.h>
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
#include <OpenGL/CGLTypes.h>
|
#include <OpenGL/CGLTypes.h>
|
||||||
|
@ -41,21 +43,24 @@ struct _GloContext {
|
||||||
* the GLO_ constants */
|
* the GLO_ constants */
|
||||||
GloContext *glo_context_create(int formatFlags)
|
GloContext *glo_context_create(int formatFlags)
|
||||||
{
|
{
|
||||||
GloContext *context;
|
CGLError err;
|
||||||
|
|
||||||
context = (GloContext *)malloc(sizeof(GloContext));
|
GloContext *context = (GloContext *)g_malloc0(sizeof(GloContext));
|
||||||
memset(context, 0, sizeof(GloContext));
|
|
||||||
|
|
||||||
/* pixel format attributes */
|
/* pixel format attributes */
|
||||||
CGLPixelFormatAttribute attributes[] = {
|
CGLPixelFormatAttribute attributes[] = {
|
||||||
kCGLPFAAccelerated,
|
kCGLPFAAccelerated,
|
||||||
(CGLPixelFormatAttribute)0
|
(CGLPixelFormatAttribute)0
|
||||||
};
|
};
|
||||||
|
|
||||||
CGLPixelFormatObj pix;
|
CGLPixelFormatObj pix;
|
||||||
GLint num;
|
GLint num;
|
||||||
CGLChoosePixelFormat(attributes, &pix, &num);
|
err = CGLChoosePixelFormat(attributes, &pix, &num);
|
||||||
CGLCreateContext(pix, NULL, &context->cglContext);
|
if (err) return NULL;
|
||||||
|
|
||||||
|
err = CGLCreateContext(pix, NULL, &context->cglContext);
|
||||||
|
if (err) return NULL;
|
||||||
|
|
||||||
CGLDestroyPixelFormat(pix);
|
CGLDestroyPixelFormat(pix);
|
||||||
|
|
||||||
glo_set_current(context);
|
glo_set_current(context);
|
||||||
|
|
|
@ -1572,12 +1572,10 @@ static void pgraph_context_init(GraphicsContext *context)
|
||||||
{
|
{
|
||||||
|
|
||||||
context->gl_context = glo_context_create(GLO_FF_DEFAULT);
|
context->gl_context = glo_context_create(GLO_FF_DEFAULT);
|
||||||
|
assert(context->gl_context);
|
||||||
/* TODO: create glo functions for Mac */
|
|
||||||
|
|
||||||
/* Check context capabilities */
|
/* Check context capabilities */
|
||||||
const GLubyte *extensions;
|
const GLubyte *extensions = glGetString(GL_EXTENSIONS);
|
||||||
extensions = glGetString (GL_EXTENSIONS);
|
|
||||||
|
|
||||||
assert(glo_check_extension((const GLubyte *)
|
assert(glo_check_extension((const GLubyte *)
|
||||||
"GL_EXT_texture_compression_s3tc",
|
"GL_EXT_texture_compression_s3tc",
|
||||||
|
@ -2156,13 +2154,11 @@ static void pgraph_method(NV2AState *d,
|
||||||
unsigned int start = GET_MASK(parameter, NV097_DRAW_ARRAYS_START_INDEX);
|
unsigned int start = GET_MASK(parameter, NV097_DRAW_ARRAYS_START_INDEX);
|
||||||
unsigned int count = GET_MASK(parameter, NV097_DRAW_ARRAYS_COUNT)+1;
|
unsigned int count = GET_MASK(parameter, NV097_DRAW_ARRAYS_COUNT)+1;
|
||||||
|
|
||||||
kelvin_update_surface(d, kelvin, true);
|
|
||||||
|
|
||||||
kelvin_bind_converted_vertex_attributes(d, kelvin,
|
kelvin_bind_converted_vertex_attributes(d, kelvin,
|
||||||
false, start + count);
|
false, start + count);
|
||||||
glDrawArrays(kelvin->gl_primitive_mode, start, count);
|
glDrawArrays(kelvin->gl_primitive_mode, start, count);
|
||||||
|
|
||||||
kelvin->surface_color.draw_dirty = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NV097_INLINE_ARRAY:
|
case NV097_INLINE_ARRAY:
|
||||||
|
|
|
@ -664,7 +664,7 @@ QString* vsh_translate(uint16_t version,
|
||||||
|
|
||||||
|
|
||||||
/* the shaders leave the result in screen space, while
|
/* the shaders leave the result in screen space, while
|
||||||
* opengl expects it in normalised device coords.
|
* opengl expects it in clip coordinates.
|
||||||
* Use the magic viewport constants for now,
|
* Use the magic viewport constants for now,
|
||||||
* but they're not necessarily present.
|
* but they're not necessarily present.
|
||||||
* Same idea as above I think, but dono what the mvp stuff is about...
|
* Same idea as above I think, but dono what the mvp stuff is about...
|
||||||
|
@ -673,7 +673,13 @@ QString* vsh_translate(uint16_t version,
|
||||||
"ADD R12, R12, -c[59];\n"
|
"ADD R12, R12, -c[59];\n"
|
||||||
"RCP R1.x, c[58].x;\n"
|
"RCP R1.x, c[58].x;\n"
|
||||||
"RCP R1.y, c[58].y;\n"
|
"RCP R1.y, c[58].y;\n"
|
||||||
"RCP R1.z, c[58].z;\n"
|
|
||||||
|
/* scale_z = view_z == 0 ? 1 : 1 / view_z */
|
||||||
|
"ABS R1.z, c[58].z;\n"
|
||||||
|
"SGE R1.z, -R1.z, 0;\n"
|
||||||
|
"ADD R1.z, R1.z, c[58].z;\n"
|
||||||
|
"RCP R1.z, R1.z;\n"
|
||||||
|
|
||||||
"MUL R12.xyz, R12, R1;\n"
|
"MUL R12.xyz, R12, R1;\n"
|
||||||
|
|
||||||
/* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection
|
/* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection
|
||||||
|
|
Loading…
Reference in New Issue