Vita: refactor gxm texture render and add SDL_RenderGeometry support
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c
index bf3af39..67a834b 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm.c
@@ -88,6 +88,14 @@ static int VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd,
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
+#if SDL_HAVE_RENDER_GEOMETRY
+static int
+VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
+ const float *xy, int xy_stride, const int *color, int color_stride, const float *uv, int uv_stride,
+ int num_vertices, const void *indices, int num_indices, int size_indices,
+ float scale_x, float scale_y);
+#endif
+
static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
static int VITA_GXM_RenderDrawPoints(SDL_Renderer *renderer, const SDL_RenderCommand *cmd);
@@ -160,7 +168,6 @@ StartDrawing(SDL_Renderer *renderer)
data->drawstate.vertex_program = NULL;
data->drawstate.fragment_program = NULL;
data->drawstate.last_command = -1;
- data->drawstate.texture_color = 0xFFFFFFFF;
data->drawstate.viewport_dirty = SDL_TRUE;
// reset blend mode
@@ -168,7 +175,6 @@ StartDrawing(SDL_Renderer *renderer)
// fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend;
// data->colorFragmentProgram = in->color;
// data->textureFragmentProgram = in->texture;
-// data->textureTintFragmentProgram = in->textureTint;
if (renderer->target == NULL) {
sceGxmBeginScene(
@@ -250,6 +256,9 @@ VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->QueueFillRects = VITA_GXM_QueueFillRects;
renderer->QueueCopy = VITA_GXM_QueueCopy;
renderer->QueueCopyEx = VITA_GXM_QueueCopyEx;
+#if SDL_HAVE_RENDER_GEOMETRY
+ renderer->QueueGeometry = VITA_GXM_QueueGeometry;
+#endif
renderer->RunCommandQueue = VITA_GXM_RunCommandQueue;
renderer->RenderReadPixels = VITA_GXM_RenderReadPixels;
renderer->RenderPresent = VITA_GXM_RenderPresent;
@@ -434,7 +443,6 @@ VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode)
}
data->colorFragmentProgram = in->color;
data->textureFragmentProgram = in->texture;
- data->textureTintFragmentProgram = in->textureTint;
data->currentBlendMode = blendMode;
}
}
@@ -479,7 +487,6 @@ VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const
{
vertex[i].x = points[i].x;
vertex[i].y = points[i].y;
- vertex[i].z = +0.5f;
vertex[i].color = color;
}
@@ -505,12 +512,10 @@ VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const S
{
vertex[i*2].x = points[i].x;
vertex[i*2].y = points[i].y;
- vertex[i*2].z = +0.5f;
vertex[i*2].color = color;
vertex[i*2+1].x = points[i+1].x;
vertex[i*2+1].y = points[i+1].y;
- vertex[i*2+1].z = +0.5f;
vertex[i*2+1].color = color;
}
@@ -538,22 +543,18 @@ VITA_GXM_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const S
vertices[4*i+0].x = rect->x;
vertices[4*i+0].y = rect->y;
- vertices[4*i+0].z = +0.5f;
vertices[4*i+0].color = color;
vertices[4*i+1].x = rect->x + rect->w;
vertices[4*i+1].y = rect->y;
- vertices[4*i+1].z = +0.5f;
vertices[4*i+1].color = color;
vertices[4*i+2].x = rect->x;
vertices[4*i+2].y = rect->y + rect->h;
- vertices[4*i+2].z = +0.5f;
vertices[4*i+2].color = color;
vertices[4*i+3].x = rect->x + rect->w;
vertices[4*i+3].y = rect->y + rect->h;
- vertices[4*i+3].z = +0.5f;
vertices[4*i+3].color = color;
}
@@ -577,6 +578,7 @@ VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture
texture_vertex *vertices;
float u0, v0, u1, v1;
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ Uint32 texture_color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | (cmd->data.draw.a << 24);
cmd->data.draw.count = 1;
@@ -595,25 +597,25 @@ VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture
vertices[0].x = dstrect->x;
vertices[0].y = dstrect->y;
- vertices[0].z = +0.5f;
+ vertices[0].color = texture_color;
vertices[0].u = u0;
vertices[0].v = v0;
vertices[1].x = dstrect->x + dstrect->w;
vertices[1].y = dstrect->y;
- vertices[1].z = +0.5f;
+ vertices[1].color = texture_color;
vertices[1].u = u1;
vertices[1].v = v0;
vertices[2].x = dstrect->x;
vertices[2].y = dstrect->y + dstrect->h;
- vertices[2].z = +0.5f;
+ vertices[2].color = texture_color;
vertices[2].u = u0;
vertices[2].v = v1;
vertices[3].x = dstrect->x + dstrect->w;
vertices[3].y = dstrect->y + dstrect->h;
- vertices[3].z = +0.5f;
+ vertices[3].color = texture_color;
vertices[3].u = u1;
vertices[3].v = v1;
@@ -633,6 +635,7 @@ VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Textur
float s, c;
const float centerx = center->x + dstrect->x;
const float centery = center->y + dstrect->y;
+ Uint32 texture_color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | (cmd->data.draw.a << 24);
cmd->data.draw.count = 1;
@@ -669,28 +672,27 @@ VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Textur
vertices[0].x = x0 - centerx;
vertices[0].y = y0 - centery;
- vertices[0].z = +0.5f;
vertices[0].u = u0;
vertices[0].v = v0;
+ vertices[0].color = texture_color;
vertices[1].x = x1 - centerx;
vertices[1].y = y0 - centery;
- vertices[1].z = +0.5f;
vertices[1].u = u1;
vertices[1].v = v0;
-
+ vertices[1].color = texture_color;
vertices[2].x = x0 - centerx;
vertices[2].y = y1 - centery;
- vertices[2].z = +0.5f;
vertices[2].u = u0;
vertices[2].v = v1;
+ vertices[2].color = texture_color;
vertices[3].x = x1 - centerx;
vertices[3].y = y1 - centery;
- vertices[3].z = +0.5f;
vertices[3].u = u1;
vertices[3].v = v1;
+ vertices[3].color = texture_color;
for (int i = 0; i < 4; ++i)
{
@@ -704,6 +706,103 @@ VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Textur
}
+#if SDL_HAVE_RENDER_GEOMETRY
+static int
+VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
+ const float *xy, int xy_stride, const int *color, int color_stride, const float *uv, int uv_stride,
+ int num_vertices, const void *indices, int num_indices, int size_indices,
+ float scale_x, float scale_y)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ int i;
+ int count = indices ? num_indices : num_vertices;
+
+ cmd->data.draw.count = count;
+ size_indices = indices ? size_indices : 0;
+
+ if (texture) {
+ texture_vertex *vertices;
+
+ vertices = (texture_vertex *)pool_memalign(
+ data,
+ count * sizeof(texture_vertex),
+ sizeof(texture_vertex));
+
+ if (!vertices) {
+ return -1;
+ }
+
+
+ for (i = 0; i < count; i++) {
+ int j;
+ float *xy_;
+ float *uv_;
+ int col_;
+ if (size_indices == 4) {
+ j = ((const Uint32 *)indices)[i];
+ } else if (size_indices == 2) {
+ j = ((const Uint16 *)indices)[i];
+ } else if (size_indices == 1) {
+ j = ((const Uint8 *)indices)[i];
+ } else {
+ j = i;
+ }
+
+ xy_ = (float *)((char*)xy + j * xy_stride);
+ col_ = *(int *)((char*)color + j * color_stride);
+ uv_ = (float *)((char*)uv + j * uv_stride);
+
+ vertices[i].x = xy_[0] * scale_x;
+ vertices[i].y = xy_[1] * scale_y;
+ vertices[i].u = uv_[0];
+ vertices[i].v = uv_[1];
+ vertices[i].color = col_;
+ }
+
+ cmd->data.draw.first = (size_t)vertices;
+
+ } else {
+ color_vertex *vertices;
+
+ vertices = (color_vertex *)pool_memalign(
+ data,
+ count * sizeof(color_vertex),
+ sizeof(color_vertex));
+
+ if (!vertices) {
+ return -1;
+ }
+
+
+ for (i = 0; i < count; i++) {
+ int j;
+ float *xy_;
+ int col_;
+ if (size_indices == 4) {
+ j = ((const Uint32 *)indices)[i];
+ } else if (size_indices == 2) {
+ j = ((const Uint16 *)indices)[i];
+ } else if (size_indices == 1) {
+ j = ((const Uint8 *)indices)[i];
+ } else {
+ j = i;
+ }
+
+ xy_ = (float *)((char*)xy + j * xy_stride);
+ col_ = *(int *)((char*)color + j * color_stride);
+
+ vertices[i].x = xy_[0] * scale_x;
+ vertices[i].y = xy_[1] * scale_y;
+ vertices[i].color = col_;
+ }
+ cmd->data.draw.first = (size_t)vertices;
+ }
+
+
+ return 0;
+}
+#endif
+
static int
VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
{
@@ -774,7 +873,7 @@ VITA_GXM_RenderFillRects(SDL_Renderer *renderer, const SDL_RenderCommand *cmd)
static int
-SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool solid)
+SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
{
SDL_Texture *texture = cmd->data.draw.texture;
const SDL_BlendMode blend = cmd->data.draw.blend;
@@ -782,13 +881,6 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool s
SceGxmVertexProgram *vertex_program;
SDL_bool matrix_updated = SDL_FALSE;
SDL_bool program_updated = SDL_FALSE;
- Uint32 texture_color;
-
- Uint8 r, g, b, a;
- r = cmd->data.draw.r;
- g = cmd->data.draw.g;
- b = cmd->data.draw.b;
- a = cmd->data.draw.a;
if (data->drawstate.viewport_dirty) {
const SDL_Rect *viewport = &data->drawstate.viewport;
@@ -834,11 +926,7 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool s
if (texture) {
vertex_program = data->textureVertexProgram;
- if(cmd->data.draw.r == 255 && cmd->data.draw.g == 255 && cmd->data.draw.b == 255 && cmd->data.draw.a == 255) {
- fragment_program = data->textureFragmentProgram;
- } else {
- fragment_program = data->textureTintFragmentProgram;
- }
+ fragment_program = data->textureFragmentProgram;
} else {
vertex_program = data->colorVertexProgram;
fragment_program = data->colorFragmentProgram;
@@ -856,58 +944,17 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool s
program_updated = SDL_TRUE;
}
- texture_color = ((a << 24) | (b << 16) | (g << 8) | r);
if (program_updated || matrix_updated) {
if (data->drawstate.fragment_program == data->textureFragmentProgram) {
void *vertex_wvp_buffer;
sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertex_wvp_buffer);
sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix);
- } else if (data->drawstate.fragment_program == data->textureTintFragmentProgram) {
- void *vertex_wvp_buffer;
- void *texture_tint_color_buffer;
- float *tint_color;
- sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertex_wvp_buffer);
- sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix);
-
- sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer);
-
- tint_color = pool_memalign(
- data,
- 4 * sizeof(float), // RGBA
- sizeof(float)
- );
-
- tint_color[0] = r / 255.0f;
- tint_color[1] = g / 255.0f;
- tint_color[2] = b / 255.0f;
- tint_color[3] = a / 255.0f;
- sceGxmSetUniformDataF(texture_tint_color_buffer, data->textureTintColorParam, 0, 4, tint_color);
- data->drawstate.texture_color = texture_color;
} else { // color
void *vertexDefaultBuffer;
sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertexDefaultBuffer);
sceGxmSetUniformDataF(vertexDefaultBuffer, data->colorWvpParam, 0, 16, data->ortho_matrix);
}
- } else {
- if (data->drawstate.fragment_program == data->textureTintFragmentProgram && data->drawstate.texture_color != texture_color) {
- void *texture_tint_color_buffer;
- float *tint_color;
- sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer);
-
- tint_color = pool_memalign(
- data,
- 4 * sizeof(float), // RGBA
- sizeof(float)
- );
-
- tint_color[0] = r / 255.0f;
- tint_color[1] = g / 255.0f;
- tint_color[2] = b / 255.0f;
- tint_color[3] = a / 255.0f;
- sceGxmSetUniformDataF(texture_tint_color_buffer, data->textureTintColorParam, 0, 4, tint_color);
- data->drawstate.texture_color = texture_color;
- }
}
if (texture != data->drawstate.texture) {
@@ -929,7 +976,7 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd)
{
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
- return SetDrawState(data, cmd, SDL_FALSE);
+ return SetDrawState(data, cmd);
}
static int
@@ -979,19 +1026,19 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *
}
case SDL_RENDERCMD_DRAW_POINTS: {
- SetDrawState(data, cmd, SDL_FALSE);
+ SetDrawState(data, cmd);
VITA_GXM_RenderDrawPoints(renderer, cmd);
break;
}
case SDL_RENDERCMD_DRAW_LINES: {
- SetDrawState(data, cmd, SDL_FALSE);
+ SetDrawState(data, cmd);
VITA_GXM_RenderDrawLines(renderer, cmd);
break;
}
case SDL_RENDERCMD_FILL_RECTS: {
- SetDrawState(data, cmd, SDL_FALSE);
+ SetDrawState(data, cmd);
VITA_GXM_RenderFillRects(renderer, cmd);
break;
}
@@ -1004,6 +1051,24 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *
break;
}
+ case SDL_RENDERCMD_GEOMETRY: {
+#if SDL_HAVE_RENDER_GEOMETRY
+ SDL_Texture *texture = cmd->data.draw.texture;
+ int ret;
+
+ if (texture) {
+ ret = SetCopyState(renderer, cmd);
+ } else {
+ ret = SetDrawState(data, cmd);
+ }
+
+ if (ret == 0) {
+ sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLES, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, cmd->data.draw.count);
+ }
+#endif
+ break;
+ }
+
case SDL_RENDERCMD_NO_OP:
break;
}
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_shaders.h b/src/render/vitagxm/SDL_render_vita_gxm_shaders.h
index 1341d32..9eb6913 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_shaders.h
+++ b/src/render/vitagxm/SDL_render_vita_gxm_shaders.h
@@ -124,37 +124,39 @@ static const unsigned char gxm_shader_color_f[gxm_shader_color_f_size] = {
0x7e, 0x0d, 0x80, 0x40,
};
-#define gxm_shader_color_v_size 352
+#define gxm_shader_color_v_size 368
static const unsigned char gxm_shader_color_v[gxm_shader_color_v_size] = {
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
- 0x5d, 0x01, 0x00, 0x00, 0x4a, 0xb6, 0x4f, 0x7b,
- 0x51, 0x19, 0x1a, 0xae, 0x00, 0x00, 0x19, 0x00,
+ 0x6d, 0x01, 0x00, 0x00, 0x09, 0xce, 0x4e, 0xc2,
+ 0xe1, 0xcd, 0x24, 0xbc, 0x00, 0x00, 0x19, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0xf0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00,
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x98, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x74, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0xa8, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00,
+ 0xb8, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf3, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x43, 0x00, 0x61,
+ 0x86, 0x81, 0xa2, 0x00, 0x07, 0x53, 0x40, 0x61,
+ 0x86, 0x81, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
0x80, 0x00, 0x08, 0x83, 0x21, 0x1d, 0x80, 0x38,
- 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40,
- 0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
- 0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
+ 0x00, 0x00, 0xf0, 0x83, 0x20, 0x0d, 0x80, 0x38,
+ 0x0a, 0x84, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18,
0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
@@ -172,142 +174,106 @@ static const unsigned char gxm_shader_color_v[gxm_shader_color_v_size] = {
0x00, 0x77, 0x76, 0x70, 0x00, 0x00, 0x00, 0x00,
};
-#define gxm_shader_texture_f_size 256
+#define gxm_shader_texture_f_size 288
static const unsigned char gxm_shader_texture_f[gxm_shader_texture_f_size] = {
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
- 0x00, 0x01, 0x00, 0x00, 0x2f, 0x18, 0xe0, 0x2b,
- 0x1f, 0x21, 0x47, 0x49, 0x01, 0x08, 0x18, 0x00,
+ 0x20, 0x01, 0x00, 0x00, 0xeb, 0x4f, 0xb5, 0xba,
+ 0x60, 0xb2, 0xd0, 0x8d, 0x05, 0x18, 0x18, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x64, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
- 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
- 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x44, 0xfa, 0x30, 0x00, 0x00, 0x00,
- 0x02, 0x04, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00,
-};
-
-#define gxm_shader_texture_tint_f_size 324
-static const unsigned char gxm_shader_texture_tint_f[gxm_shader_texture_tint_f_size] = {
- 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
- 0x43, 0x01, 0x00, 0x00, 0x44, 0x2f, 0x5d, 0xfe,
- 0x9e, 0xda, 0xf8, 0x6f, 0x05, 0x08, 0x18, 0x00,
- 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0xcc, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00,
0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x84, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
+ 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0xa9, 0xd0, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x44, 0xfa, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x99, 0xff,
- 0xbc, 0x0d, 0xc0, 0x40, 0x02, 0x80, 0xb9, 0xaf,
+ 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x99, 0xaf,
+ 0xbc, 0x0d, 0xc0, 0x40, 0x06, 0x82, 0xb9, 0xaf,
0xbc, 0x0d, 0x80, 0x40, 0x7c, 0x0f, 0x04, 0x00,
- 0x86, 0x47, 0xa4, 0x10, 0x0e, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00,
- 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
+ 0x86, 0x47, 0xa4, 0x10, 0x30, 0x00, 0x00, 0x00,
0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x75, 0x54, 0x69, 0x6e,
- 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74,
- 0x65, 0x78, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00,
};
-#define gxm_shader_texture_v_size 344
+#define gxm_shader_texture_v_size 400
static const unsigned char gxm_shader_texture_v[gxm_shader_texture_v_size] = {
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
- 0x58, 0x01, 0x00, 0x00, 0xa3, 0x36, 0x7b, 0x62,
- 0x1b, 0x80, 0x1c, 0xb0, 0x00, 0x00, 0x19, 0x00,
+ 0x8f, 0x01, 0x00, 0x00, 0x60, 0x1e, 0x69, 0x97,
+ 0x82, 0x7e, 0x0c, 0xac, 0x00, 0x00, 0x19, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0xe8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x08, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00,
+ 0x98, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x74, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
+ 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x33, 0x0f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x0a,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x43, 0x00, 0x61,
+ 0x86, 0x81, 0xa2, 0x00, 0x07, 0x53, 0x40, 0x61,
+ 0x86, 0x81, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
- 0x80, 0x00, 0x08, 0x83, 0x21, 0x0d, 0x80, 0x38,
- 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40,
- 0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
- 0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
+ 0x01, 0x0e, 0x01, 0x01, 0x02, 0x00, 0x10, 0xfa,
+ 0x80, 0x00, 0x08, 0x83, 0x21, 0x25, 0x80, 0x38,
+ 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x14, 0xfa,
+ 0x00, 0x00, 0xf0, 0x83, 0x20, 0x0d, 0x80, 0x38,
+ 0x0a, 0x84, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18,
0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x3a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
+ 0x34, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x2b, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x00, 0x61, 0x54, 0x65, 0x78, 0x63, 0x6f,
- 0x6f, 0x72, 0x64, 0x00, 0x77, 0x76, 0x70, 0x00,
+ 0x6f, 0x72, 0x64, 0x00, 0x61, 0x43, 0x6f, 0x6c,
+ 0x6f, 0x72, 0x00, 0x77, 0x76, 0x70, 0x00, 0x00,
};
-
-static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram*)gxm_shader_clear_v;
+static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram *)gxm_shader_clear_v;
static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f;
static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v;
static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f;
static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v;
static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f;
-static const SceGxmProgram *const textureTintFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_tint_f;
#endif // SDL_RENDER_VITA_GXM_SHADERS_H
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
index fe9ff61..2190b66 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -164,7 +164,6 @@ free_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out)
{
sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->color);
sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->texture);
- sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->textureTint);
}
static void
@@ -202,21 +201,6 @@ make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out,
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err);
return;
}
-
- err = sceGxmShaderPatcherCreateFragmentProgram(
- data->shaderPatcher,
- data->textureTintFragmentProgramId,
- SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
- 0,
- blend_info,
- textureVertexProgramGxp,
- &out->textureTint
- );
-
- if (err != 0) {
- SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err);
- return;
- }
}
@@ -232,22 +216,18 @@ set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h)
vertices[0].x = x;
vertices[0].y = y;
- vertices[0].z = +0.5f;
vertices[0].color = 0;
vertices[1].x = x + w;
vertices[1].y = y;
- vertices[1].z = +0.5f;
vertices[1].color = 0;
vertices[2].x = x;
vertices[2].y = y + h;
- vertices[2].z = +0.5f;
vertices[2].color = 0;
vertices[3].x = x + w;
vertices[3].y = y + h;
- vertices[3].z = +0.5f;
vertices[3].color = 0;
data->drawstate.fragment_program = data->colorFragmentProgram;
@@ -654,12 +634,6 @@ gxm_init(SDL_Renderer *renderer)
return err;
}
- err = sceGxmProgramCheck(textureTintFragmentProgramGxp);
- if (err != 0) {
- SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (texture tint fragment) failed: %d\n", err);
- return err;
- }
-
// register programs with the patcher
err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, clearVertexProgramGxp, &data->clearVertexProgramId);
if (err != 0) {
@@ -697,13 +671,6 @@ gxm_init(SDL_Renderer *renderer)
return err;
}
- err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, textureTintFragmentProgramGxp, &data->textureTintFragmentProgramId);
- if (err != 0) {
- SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (texture tint fragment) failed: %d\n", err);
- return err;
- }
-
-
{
// get attributes by name to create vertex format bindings
const SceGxmProgramParameter *paramClearPositionAttribute = sceGxmProgramFindParameterByName(clearVertexProgramGxp, "aPosition");
@@ -789,15 +756,15 @@ gxm_init(SDL_Renderer *renderer)
// create color vertex format
SceGxmVertexAttribute colorVertexAttributes[2];
SceGxmVertexStream colorVertexStreams[1];
- /* x,y,z: 3 float 32 bits */
+ /* x,y: 2 float 32 bits */
colorVertexAttributes[0].streamIndex = 0;
colorVertexAttributes[0].offset = 0;
colorVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
- colorVertexAttributes[0].componentCount = 3; // (x, y, z)
+ colorVertexAttributes[0].componentCount = 2; // (x, y)
colorVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorPositionAttribute);
/* color: 4 unsigned char = 32 bits */
colorVertexAttributes[1].streamIndex = 0;
- colorVertexAttributes[1].offset = 12; // (x, y, z) * 4 = 12 bytes
+ colorVertexAttributes[1].offset = 8; // (x, y) * 4 = 8 bytes
colorVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N;
colorVertexAttributes[1].componentCount = 4; // (color)
colorVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorColorAttribute);
@@ -826,22 +793,29 @@ gxm_init(SDL_Renderer *renderer)
{
const SceGxmProgramParameter *paramTexturePositionAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aPosition");
const SceGxmProgramParameter *paramTextureTexcoordAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aTexcoord");
+ const SceGxmProgramParameter *paramTextureColorAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aColor");
// create texture vertex format
- SceGxmVertexAttribute textureVertexAttributes[2];
+ SceGxmVertexAttribute textureVertexAttributes[3];
SceGxmVertexStream textureVertexStreams[1];
- /* x,y,z: 3 float 32 bits */
+ /* x,y: 2 float 32 bits */
textureVertexAttributes[0].streamIndex = 0;
textureVertexAttributes[0].offset = 0;
textureVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
- textureVertexAttributes[0].componentCount = 3; // (x, y, z)
+ textureVertexAttributes[0].componentCount = 2; // (x, y)
textureVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramTexturePositionAttribute);
/* u,v: 2 floats 32 bits */
textureVertexAttributes[1].streamIndex = 0;
- textureVertexAttributes[1].offset = 12; // (x, y, z) * 4 = 12 bytes
+ textureVertexAttributes[1].offset = 8; // (x, y) * 4 = 8 bytes
textureVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
textureVertexAttributes[1].componentCount = 2; // (u, v)
textureVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTexcoordAttribute);
+ /* r,g,b,a: 4 unsigned chars 32 bits */
+ textureVertexAttributes[2].streamIndex = 0;
+ textureVertexAttributes[2].offset = 16; // (x, y, u, v) * 4 = 16 bytes
+ textureVertexAttributes[2].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N;
+ textureVertexAttributes[2].componentCount = 4; // (r, g, b, a)
+ textureVertexAttributes[2].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureColorAttribute);
// 16 bit (short) indices
textureVertexStreams[0].stride = sizeof(texture_vertex);
textureVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
@@ -851,13 +825,13 @@ gxm_init(SDL_Renderer *renderer)
data->shaderPatcher,
data->textureVertexProgramId,
textureVertexAttributes,
- 2,
+ 3,
textureVertexStreams,
1,
&data->textureVertexProgram
);
if (err != 0) {
- SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (texture vertex) failed: %d\n", err);
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (texture vertex) failed: %x\n", err);
return err;
}
@@ -876,7 +850,6 @@ gxm_init(SDL_Renderer *renderer)
data->colorFragmentProgram = in->color;
data->textureFragmentProgram = in->texture;
- data->textureTintFragmentProgram = in->textureTint;
}
@@ -884,7 +857,6 @@ gxm_init(SDL_Renderer *renderer)
data->clearClearColorParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(clearFragmentProgramGxp, "uClearColor");
data->colorWvpParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(colorVertexProgramGxp, "wvp");
data->textureWvpParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(textureVertexProgramGxp, "wvp");
- data->textureTintColorParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(textureTintFragmentProgramGxp, "uTintColor");
// Allocate memory for the memory pool
data->pool_addr[0] = mem_gpu_alloc(
@@ -963,7 +935,6 @@ void gxm_finish(SDL_Renderer *renderer)
sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->colorFragmentProgramId);
sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->colorVertexProgramId);
sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureFragmentProgramId);
- sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureTintFragmentProgramId);
sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureVertexProgramId);
sceGxmShaderPatcherDestroy(data->shaderPatcher);
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h
index 8f94e28..3dd6dc4 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_types.h
+++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h
@@ -61,16 +61,15 @@ typedef struct clear_vertex {
typedef struct color_vertex {
float x;
float y;
- float z;
unsigned int color;
} color_vertex;
typedef struct texture_vertex {
float x;
float y;
- float z;
float u;
float v;
+ unsigned int color;
} texture_vertex;
typedef struct gxm_texture {
@@ -85,7 +84,6 @@ typedef struct gxm_texture {
typedef struct fragment_programs {
SceGxmFragmentProgram *color;
SceGxmFragmentProgram *texture;
- SceGxmFragmentProgram *textureTint;
} fragment_programs;
typedef struct blend_fragment_programs {
@@ -103,7 +101,6 @@ typedef struct
SDL_Texture *texture;
SDL_Texture *target;
Uint32 color;
- Uint32 texture_color;
SceGxmFragmentProgram *fragment_program;
SceGxmVertexProgram *vertex_program;
int last_command;
@@ -162,11 +159,9 @@ typedef struct
SceGxmFragmentProgram *colorFragmentProgram;
SceGxmVertexProgram *textureVertexProgram;
SceGxmFragmentProgram *textureFragmentProgram;
- SceGxmFragmentProgram *textureTintFragmentProgram;
SceGxmProgramParameter *clearClearColorParam;
SceGxmProgramParameter *colorWvpParam;
SceGxmProgramParameter *textureWvpParam;
- SceGxmProgramParameter *textureTintColorParam;
SceGxmShaderPatcher *shaderPatcher;
SceGxmVertexProgram *clearVertexProgram;
@@ -178,7 +173,6 @@ typedef struct
SceGxmShaderPatcherId colorFragmentProgramId;
SceGxmShaderPatcherId textureVertexProgramId;
SceGxmShaderPatcherId textureFragmentProgramId;
- SceGxmShaderPatcherId textureTintFragmentProgramId;
SceUID patcherBufferUid;
SceUID patcherVertexUsseUid;
diff --git a/src/render/vitagxm/shader_src/color_v.cg b/src/render/vitagxm/shader_src/color_v.cg
index 7132560..4966099 100644
--- a/src/render/vitagxm/shader_src/color_v.cg
+++ b/src/render/vitagxm/shader_src/color_v.cg
@@ -1,5 +1,5 @@
void main(
- float3 aPosition,
+ float2 aPosition,
float4 aColor,
uniform float4x4 wvp,
out float4 vPosition : POSITION,
@@ -7,7 +7,7 @@ void main(
out float pSize : PSIZE
)
{
- vPosition = mul(float4(aPosition, 1.f), wvp);
+ vPosition = mul(float4(aPosition, 1.f, 0.5f), wvp);
vColor = aColor;
pSize = 1.f;
}
diff --git a/src/render/vitagxm/shader_src/texture_f.cg b/src/render/vitagxm/shader_src/texture_f.cg
index 232ee85..a1f63b8 100644
--- a/src/render/vitagxm/shader_src/texture_f.cg
+++ b/src/render/vitagxm/shader_src/texture_f.cg
@@ -1,4 +1,4 @@
-float4 main(float2 vTexcoord : TEXCOORD0, uniform sampler2D tex)
+float4 main(float2 vTexcoord : TEXCOORD0, float4 vColor : COLOR, uniform sampler2D tex)
{
- return tex2D(tex, vTexcoord);
+ return tex2D(tex, vTexcoord) * vColor;
}
diff --git a/src/render/vitagxm/shader_src/texture_tint_f.cg b/src/render/vitagxm/shader_src/texture_tint_f.cg
deleted file mode 100644
index 8b12a80..0000000
--- a/src/render/vitagxm/shader_src/texture_tint_f.cg
+++ /dev/null
@@ -1,4 +0,0 @@
-float4 main( float2 vTexcoord : TEXCOORD0, uniform sampler2D tex, uniform float4 uTintColor)
-{
- return tex2D(tex, vTexcoord) * uTintColor;
-}
diff --git a/src/render/vitagxm/shader_src/texture_v.cg b/src/render/vitagxm/shader_src/texture_v.cg
index 8be0f54..9e05e9a 100644
--- a/src/render/vitagxm/shader_src/texture_v.cg
+++ b/src/render/vitagxm/shader_src/texture_v.cg
@@ -1,11 +1,14 @@
void main(
- float3 aPosition,
+ float2 aPosition,
float2 aTexcoord,
+ float4 aColor,
uniform float4x4 wvp,
out float4 vPosition : POSITION,
+ out float4 vColor : COLOR,
out float2 vTexcoord : TEXCOORD0
)
{
- vPosition = mul(float4(aPosition, 1.f), wvp);
+ vPosition = mul(float4(aPosition, 1.f, 0.5f), wvp);
vTexcoord = aTexcoord;
+ vColor = aColor;
}