All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-devel] [PATCH v2 4/7] console-gl: add opengl rendering helper functions
Date: Tue, 20 Jan 2015 08:54:47 -0500	[thread overview]
Message-ID: <54BE5E27.7040807@redhat.com> (raw)
In-Reply-To: <1421751643.3606.30.camel@nilsson.home.kraxel.org>

On 2015-01-20 at 06:00, Gerd Hoffmann wrote:
>    Hi,
>
>>> +static GLchar texture_blit_vert_src[] =
>>> +    "\n"
>>> +    "#version 300 es\n"
>>> +    "\n"
>>> +    "in vec2  in_position;\n"
>>> +    "in vec2  in_tex_coord;\n"
>> You could calculate the texture coordinate from the position in the
>> shader, but this is mostly my premature optimization instinct kicking in
>> instead of a real performance difference considering how few vertices
>> there are in this case.
> Still makes sense.  Done.
>
>>> +    "out vec2 ex_tex_coord;\n"
>>> +    "\n"
>>> +    "void main(void) {\n"
>>> +    "    gl_Position = vec4(in_position.x, in_position.y, 0.0, 1.0);\n"
>> vec4(in_position, 0.0, 1.0) *cough*
> Done.
>
>> This looks like a list for GL_TRIANGLES instead of GL_TRIANGLE_STRIP.
>> For GL_TRIANGLE_STRIP, you first define one whole triangle (by
>> specifying each of the three vertices) and after that, each vertex
>> results in a new triangle drawn (whose two other vertices are the two
>> vertices preceding the last one).
> Thanks for the nice description.
>
> So the trick to get it done with only four vertexes is to put the
> correct points (which are going to be shared by both triangles) into the
> middle.  I've played around with it a bit without success (and before my
> new opengl book arrived), and this 6-point version worked ...

Hm, I did write a working solution in my reply, didn't I? It was: { -1, 
-1,   1, -1,   -1, 1,   1, 1 } for in_position[] and { 0, 1, 1, 1,   0, 
0,   1, 0 } for in_tex_coord[]. At least it worked for me.

You haven't (explicitly) enabled face culling, but remember that while 
normally counter-clockwise faces are backfaces and thus culled, the 
direction is inverted for every triangle; so the first triangle needs to 
be CCW, the second CW, the third CCW again, and so on. Maybe that's why 
it didn't work for you...

>>> +    glUseProgram(gls->texture_blit_prog);
>>> +    l_position = glGetAttribLocation(gls->texture_blit_prog, "in_position");
>>> +    l_tex_coord = glGetAttribLocation(gls->texture_blit_prog, "in_tex_coord");
>>> +    glVertexAttribPointer(l_position, 2, GL_FLOAT, GL_FALSE, 0, in_position);
>>> +    glVertexAttribPointer(l_tex_coord, 2, GL_FLOAT, GL_FALSE, 0, in_tex_coord);
>> I think it is disallowed to refer to non-OpenGL buffers here in the core
>> profile. The 4.4 core specification states (section 10.3, vertex
>> arrays): "Vertex data are placed into arrays that are stored in the
>> server’s address space"; the 4.4 compatibility specification states:
>> "Vertex data may also be placed into arrays that are stored in the
>> client’s address space (described here) or in the server’s address space".
> Got this from gles sample code, so that should be ok ;)
>
> I've also seen code explicitly storing vertex data in a buffer, which I
> assume is more efficient, but I decided to not care for now, especially
> given the small number of vertexes we are processing here.
>
>>> +    return gl_create_link_program(vert_shader, frag_shader);
>> Minor thing: You are free to delete the shaders after they have been
>> linked into the program (because the references will be lost when this
>> function returns).
> Done.
>
>>> +    switch (surface->format) {
>>> +    case PIXMAN_BE_b8g8r8x8:
>>> +    case PIXMAN_BE_b8g8r8a8:
>>> +        surface->glformat = GL_BGRA_EXT;
>> If you want to avoid the _EXT, you could use GL_RGBA here and
>> texture().bgra in the fragment shader. However, this would require a
>> different shader for the 32 bit and the 16 bit formats (because the 16
>> bit format has the right order, apparently).
> At least it worked in testing.
>
>> I haven't been able to really test 16 bit mode (forcing 16 bit mode in
>> hw/display/vga.c doesn't count...), so I'm trusting you this works.
> -kernel /boot/vmlinux-$whatever -append vga=0x314
>
> Makes the kernel run vesafb with 800x600 @ 16bpp, and thanks to the
> little friendly penguin in the upper left corner (CONFIG_LOGO=y) you can
> easily spot colors being messed up.

Thanks!

Max

  reply	other threads:[~2015-01-20 13:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19 13:36 [Qemu-devel] [PATCH v2 0/7] sdl2: add opengl rendering support Gerd Hoffmann
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 1/7] configure: opengl overhaul Gerd Hoffmann
2015-01-19 14:43   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 2/7] Allow the use of X11 from a non standard location Gerd Hoffmann
2015-01-19 14:50   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 3/7] pixman: add a bunch of PIXMAN_BE_* defines for 32bpp Gerd Hoffmann
2015-01-19 14:54   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 4/7] console-gl: add opengl rendering helper functions Gerd Hoffmann
2015-01-19 16:05   ` Max Reitz
2015-01-20 11:00     ` Gerd Hoffmann
2015-01-20 13:54       ` Max Reitz [this message]
2015-01-20 14:44         ` Gerd Hoffmann
2015-01-20 14:52           ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 5/7] console-gl: externalize shader programs Gerd Hoffmann
2015-01-19 16:15   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 6/7] sdl2: move SDL_* includes to sdl2.h Gerd Hoffmann
2015-01-19 16:16   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 7/7] sdl2: add support for display rendering using opengl Gerd Hoffmann
2015-01-19 16:22   ` Max Reitz
2015-01-20 11:13     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54BE5E27.7040807@redhat.com \
    --to=mreitz@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.