comparison src/video/SDL_renderer_gl.c @ 2848:8a3aa505ecba

Comment cleanup.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 07 Dec 2008 07:16:40 +0000
parents 7d020441fa81
children a38fcb093081
comparison
equal deleted inserted replaced
2847:7d020441fa81 2848:8a3aa505ecba
526 (int) pos, (const char *) errstr); 526 (int) pos, (const char *) errstr);
527 #endif 527 #endif
528 data->glBindProgramARB(shader_type, 0); 528 data->glBindProgramARB(shader_type, 0);
529 data->glDeleteProgramsARB(1, &program); 529 data->glDeleteProgramsARB(1, &program);
530 return 0; 530 return 0;
531 } // if 531 }
532 532
533 return program; 533 return program;
534 } 534 }
535 535
536 // UYVY to RGB equasion... 536
537 // R = 1.164(Y-16) + 1.596(Cr-128) 537 /*
538 // G = 1.164(Y-16) - 0.813(Cr-128) - 0.391(Cb-128) 538 * Fragment program that renders from UYVY textures.
539 // B = 1.164(Y-16) + 2.018(Cb-128) 539 * The UYVY to RGB equasion is:
540 // Byte layout is Cb, Y1, Cr, Y2. 540 * R = 1.164(Y-16) + 1.596(Cr-128)
541 // 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr 541 * G = 1.164(Y-16) - 0.813(Cr-128) - 0.391(Cb-128)
542 // !!! FIXME: this ignores blendmodes, etc. 542 * B = 1.164(Y-16) + 2.018(Cb-128)
543 // !!! FIXME: this could be more efficient...use a dot product for green, etc. 543 * Byte layout is Cb, Y1, Cr, Y2, stored in the R, G, B, A channels.
544 * 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr
545 *
546 * !!! FIXME: this ignores blendmodes, etc.
547 * !!! FIXME: this could be more efficient...use a dot product for green, etc.
548 */
544 static const char *fragment_program_UYVY_source_code = 549 static const char *fragment_program_UYVY_source_code =
545 "!!ARBfp1.0\n" 550 "!!ARBfp1.0\n"
546 551
547 // outputs... 552 /* outputs... */
548 "OUTPUT outcolor = result.color;\n" 553 "OUTPUT outcolor = result.color;\n"
549 554
550 // scratch registers... 555 /* scratch registers... */
551 "TEMP uyvy;\n" 556 "TEMP uyvy;\n"
552 "TEMP luminance;\n" 557 "TEMP luminance;\n"
553 "TEMP work;\n" 558 "TEMP work;\n"
554 559
555 // We need 32 bits to store the data, but each pixel is 16 bits in itself. 560 /* Halve the coordinates to grab the correct 32 bits for the fragment. */
556 // halve the coordinates to grab the correct 32 bits for the fragment.
557 "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n" 561 "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n"
558 562
559 // Sample the YUV texture. Cb, Y1, Cr, Y2, are stored x,y,z,w 563 /* Sample the YUV texture. Cb, Y1, Cr, Y2, are stored in x, y, z, w. */
560 "TEX uyvy, work, texture[0], %TEXTURETARGET%;\n" 564 "TEX uyvy, work, texture[0], %TEXTURETARGET%;\n"
561 565
562 // Do subtractions (128/255, 16/255, 128/255, 16/255) 566 /* Do subtractions (128/255, 16/255, 128/255, 16/255) */
563 "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n" 567 "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n"
564 568
565 // Choose the luminance component by texcoord. 569 /* Choose the luminance component by texcoord. */
566 // !!! FIXME: laziness wins out for now... just average Y1 and Y2. 570 /* !!! FIXME: laziness wins out for now... just average Y1 and Y2. */
567 "ADD luminance, uyvy.yyyy, uyvy.wwww;\n" 571 "ADD luminance, uyvy.yyyy, uyvy.wwww;\n"
568 "MUL luminance, luminance, { 0.5, 0.5, 0.5, 0.5 };\n" 572 "MUL luminance, luminance, { 0.5, 0.5, 0.5, 0.5 };\n"
569 573
570 // Multiply luminance by its magic value. 574 /* Multiply luminance by its magic value. */
571 "MUL luminance, luminance, { 1.164, 1.164, 1.164, 1.164 };\n" 575 "MUL luminance, luminance, { 1.164, 1.164, 1.164, 1.164 };\n"
572 576
573 // uyvy.xyzw becomes Cr/Cr/Cb/Cb, with multiplications. 577 /* uyvy.xyzw becomes Cr/Cr/Cb/Cb, with multiplications. */
574 "MUL uyvy, uyvy.zzxx, { 1.596, -0.813, 2.018, -0.391 };\n" 578 "MUL uyvy, uyvy.zzxx, { 1.596, -0.813, 2.018, -0.391 };\n"
575 579
576 // Add luminance Cr and Cb, store to RGB channels. 580 /* Add luminance to Cr and Cb, store to RGB channels. */
577 "ADD work.rgb, luminance, uyvy;\n" 581 "ADD work.rgb, luminance, uyvy;\n"
578 582
579 // Do final addition for Green channel. (!!! FIXME: this should be a DPH?) 583 /* Do final addition for Green channel. (!!! FIXME: this should be a DPH?) */
580 "ADD work.g, work.g, uyvy.w;\n" 584 "ADD work.g, work.g, uyvy.w;\n"
581 585
582 // Make sure alpha channel is fully opaque. (!!! FIXME: blend modes!) 586 /* Make sure alpha channel is fully opaque. (!!! FIXME: blend modes!) */
583 "MOV work.a, { 1.0 };\n" 587 "MOV work.a, { 1.0 };\n"
584 588
585 // Store out the final fragment color. 589 /* Store out the final fragment color... */
586 "MOV outcolor, work;\n" 590 "MOV outcolor, work;\n"
587 591
588 // ...and we're done. 592 /* ...and we're done! */
589 "END\n"; 593 "END\n";
590 594
591 595
592 static int 596 static int
593 GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) 597 GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)