Mercurial > sdl-ios-xcode
annotate src/video/ps3/SDL_ps3render.c @ 3150:0cf7bff804ad gsoc2009_ps3
Code reviewed and added SPE API documentation.
author | Martin Lowinski <martin@goldtopf.org> |
---|---|
date | Sun, 19 Jul 2009 11:31:47 +0000 |
parents | 104786a909a2 |
children | 7f3341cccf42 |
rev | line source |
---|---|
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
1 /* |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
4 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
9 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
14 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
18 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
19 Sam Lantinga |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
21 */ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
23 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
24 #include "SDL_video.h" |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
25 #include "../SDL_sysvideo.h" |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
26 #include "../SDL_yuv_sw_c.h" |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
27 #include "../SDL_renderer_sw.h" |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
28 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
29 #include "SDL_ps3video.h" |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
30 #include "SDL_ps3spe_c.h" |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
31 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
32 #include <fcntl.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
33 #include <stdlib.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
34 #include <sys/ioctl.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
35 #include <linux/kd.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
36 #include <linux/fb.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
37 #include <sys/mman.h> |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
38 #include <asm/ps3fb.h> |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
39 |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
40 |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
41 /* Stores the executable name */ |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
42 extern spe_program_handle_t yuv2rgb_spu; |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
43 extern spe_program_handle_t bilin_scaler_spu; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
44 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
45 /* SDL surface based renderer implementation */ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
46 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
47 static SDL_Renderer *SDL_PS3_CreateRenderer(SDL_Window * window, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
48 Uint32 flags); |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
49 static int SDL_PS3_ActivateRenderer(SDL_Renderer * renderer); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
50 static int SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
51 static int SDL_PS3_RenderLine(SDL_Renderer * renderer, int x1, int y1, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
52 int x2, int y2); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
53 static int SDL_PS3_RenderFill(SDL_Renderer * renderer, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
54 const SDL_Rect * rect); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
55 static int SDL_PS3_RenderCopy(SDL_Renderer * renderer, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
56 SDL_Texture * texture, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
57 const SDL_Rect * srcrect, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
58 const SDL_Rect * dstrect); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
59 static void SDL_PS3_RenderPresent(SDL_Renderer * renderer); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
60 static void SDL_PS3_DestroyRenderer(SDL_Renderer * renderer); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
61 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
62 /* Texture */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
63 static int PS3_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
64 static int PS3_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, void **pixels, int *pitch); |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
65 static int PS3_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
66 static int PS3_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, int markDirty, void **pixels, int *pitch); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
67 static void PS3_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
68 static void PS3_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
69 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
70 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
71 SDL_RenderDriver SDL_PS3_RenderDriver = { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
72 SDL_PS3_CreateRenderer, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
73 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
74 "ps3", |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
75 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTVSYNC | |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
76 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
77 SDL_RENDERER_ACCELERATED), |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
78 (SDL_TEXTUREMODULATE_NONE), |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
79 (SDL_BLENDMODE_NONE), |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
80 /* We use bilinear scaling on the SPE for YV12 & IYUV |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
81 * (width and height % 8 = 0) */ |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
82 (SDL_TEXTURESCALEMODE_SLOW) |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
83 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
84 }; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
85 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
86 typedef struct |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
87 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
88 int current_screen; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
89 SDL_Surface *screen; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
90 SDL_VideoDisplay *display; |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
91 /* adress of the centered image in the framebuffer (double buffered) */ |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
92 uint8_t *center[2]; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
93 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
94 /* width of input (bounded by writeable width) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
95 unsigned int bounded_width; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
96 /* height of input (bounded by writeable height) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
97 unsigned int bounded_height; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
98 /* offset from the left side (used for centering) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
99 unsigned int offset_left; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
100 /* offset from the upper side (used for centering) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
101 unsigned int offset_top; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
102 /* width of screen which is writeable */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
103 unsigned int wr_width; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
104 /* width of screen which is writeable */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
105 unsigned int wr_height; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
106 /* size of a screen line: width * bpp/8 */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
107 unsigned int line_length; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
108 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
109 /* Use two buffers in fb? res < 720p */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
110 unsigned int double_buffering; |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
111 |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
112 /* SPE threading stuff */ |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
113 spu_data_t *converter_thread_data; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
114 spu_data_t *scaler_thread_data; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
115 |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
116 /* YUV converting transfer data */ |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
117 volatile struct yuv2rgb_parms_t * converter_parms __attribute__((aligned(128))); |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
118 /* Scaler transfer data */ |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
119 volatile struct scale_parms_t * scaler_parms __attribute__((aligned(128))); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
120 } SDL_PS3_RenderData; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
121 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
122 typedef struct |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
123 { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
124 int pitch; |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
125 /* Image data */ |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
126 volatile void *pixels; |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
127 /* Use software renderer for not supported formats */ |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
128 SDL_SW_YUVTexture *yuv; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
129 /* Can we use the SPE to process this texture? */ |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
130 unsigned int accelerated; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
131 } PS3_TextureData; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
132 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
133 SDL_Renderer * |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
134 SDL_PS3_CreateRenderer(SDL_Window * window, Uint32 flags) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
135 { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
136 deprintf(1, "+SDL_PS3_CreateRenderer()\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
137 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
138 SDL_DisplayMode *displayMode = &display->current_mode; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
139 SDL_Renderer *renderer; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
140 SDL_PS3_RenderData *data; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
141 int i, n; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
142 int bpp; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
143 Uint32 Rmask, Gmask, Bmask, Amask; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
144 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
145 if (!SDL_PixelFormatEnumToMasks |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
146 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
147 SDL_SetError("Unknown display format"); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
148 return NULL; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
149 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
150 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
151 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
152 if (!renderer) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
153 SDL_OutOfMemory(); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
154 return NULL; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
155 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
156 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
157 data = (SDL_PS3_RenderData *) SDL_malloc(sizeof(*data)); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
158 if (!data) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
159 SDL_PS3_DestroyRenderer(renderer); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
160 SDL_OutOfMemory(); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
161 return NULL; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
162 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
163 SDL_zerop(data); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
164 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
165 renderer->CreateTexture = PS3_CreateTexture; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
166 renderer->DestroyTexture = PS3_DestroyTexture; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
167 renderer->QueryTexturePixels = PS3_QueryTexturePixels; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
168 renderer->UpdateTexture = PS3_UpdateTexture; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
169 renderer->LockTexture = PS3_LockTexture; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
170 renderer->UnlockTexture = PS3_UnlockTexture; |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
171 renderer->ActivateRenderer = SDL_PS3_ActivateRenderer; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
172 renderer->RenderPoint = SDL_PS3_RenderPoint; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
173 renderer->RenderLine = SDL_PS3_RenderLine; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
174 renderer->RenderFill = SDL_PS3_RenderFill; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
175 renderer->RenderCopy = SDL_PS3_RenderCopy; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
176 renderer->RenderPresent = SDL_PS3_RenderPresent; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
177 renderer->DestroyRenderer = SDL_PS3_DestroyRenderer; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
178 renderer->info.name = SDL_PS3_RenderDriver.info.name; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
179 renderer->info.flags = 0; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
180 renderer->window = window->id; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
181 renderer->driverdata = data; |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
182 //Setup_SoftwareRenderer(renderer); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
183 |
3143
8fdabaa064c3
Fixed centering. Added debug msgs for RenderCopy().
Martin Lowinski <martin@goldtopf.org>
parents:
3142
diff
changeset
|
184 deprintf(1, "window->w = %u\n", window->w); |
8fdabaa064c3
Fixed centering. Added debug msgs for RenderCopy().
Martin Lowinski <martin@goldtopf.org>
parents:
3142
diff
changeset
|
185 deprintf(1, "window->h = %u\n", window->h); |
8fdabaa064c3
Fixed centering. Added debug msgs for RenderCopy().
Martin Lowinski <martin@goldtopf.org>
parents:
3142
diff
changeset
|
186 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
187 data->double_buffering = 0; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
188 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
189 if (flags & SDL_RENDERER_PRESENTFLIP2) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
190 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
191 n = 2; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
192 data->double_buffering = 1; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
193 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
194 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
195 n = 1; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
196 } |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
197 |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
198 data->screen = |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
199 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask, |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
200 Bmask, Amask); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
201 if (!data->screen) { |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
202 SDL_PS3_DestroyRenderer(renderer); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
203 return NULL; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
204 } |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
205 /* Allocate aligned memory for pixels */ |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
206 SDL_free(data->screen->pixels); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
207 data->screen->pixels = (void *)memalign(16, data->screen->h * data->screen->pitch); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
208 if (!data->screen->pixels) { |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
209 SDL_FreeSurface(data->screen); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
210 SDL_OutOfMemory(); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
211 return NULL; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
212 } |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
213 SDL_memset(data->screen->pixels, 0, data->screen->h * data->screen->pitch); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
214 SDL_SetSurfacePalette(data->screen, display->palette); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
215 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
216 data->current_screen = 0; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
217 |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
218 /* Create SPU parms structure */ |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
219 data->converter_parms = (struct yuv2rgb_parms_t *) memalign(16, sizeof(struct yuv2rgb_parms_t)); |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
220 data->scaler_parms = (struct scale_parms_t *) memalign(16, sizeof(struct scale_parms_t)); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
221 if (data->converter_parms == NULL || data->scaler_parms == NULL) { |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
222 SDL_PS3_DestroyRenderer(renderer); |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
223 SDL_OutOfMemory(); |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
224 return NULL; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
225 } |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
226 |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
227 /* Set up the SPEs */ |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
228 data->converter_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t)); |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
229 data->scaler_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t)); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
230 if (data->converter_thread_data == NULL || data->scaler_thread_data == NULL) { |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
231 SDL_PS3_DestroyRenderer(renderer); |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
232 SDL_OutOfMemory(); |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
233 return NULL; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
234 } |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
235 |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
236 /* Set up the SPE scaler */ |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
237 data->scaler_thread_data->program = bilin_scaler_spu; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
238 data->scaler_thread_data->program_name = "bilin_scaler_spu"; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
239 data->scaler_thread_data->keepalive = 0; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
240 data->scaler_thread_data->booted = 0; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
241 |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
242 /* Set up the SPE converter */ |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
243 data->converter_thread_data->program = yuv2rgb_spu; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
244 data->converter_thread_data->program_name = "yuv2rgb_spu"; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
245 data->converter_thread_data->keepalive = 1; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
246 data->converter_thread_data->booted = 0; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
247 |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
248 SPE_Start(data->converter_thread_data); |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
249 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
250 deprintf(1, "-SDL_PS3_CreateRenderer()\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
251 return renderer; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
252 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
253 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
254 static int |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
255 SDL_PS3_ActivateRenderer(SDL_Renderer * renderer) |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
256 { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
257 deprintf(1, "+PS3_ActivateRenderer()\n"); |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
258 SDL_PS3_RenderData *data = (SDL_PS3_RenderData *) renderer->driverdata; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
259 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
260 deprintf(1, "-PS3_ActivateRenderer()\n"); |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
261 return 0; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
262 } |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
263 |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
264 static int |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
265 PS3_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
266 deprintf(1, "+PS3_CreateTexture()\n"); |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
267 PS3_TextureData *data; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
268 data = (PS3_TextureData *) SDL_calloc(1, sizeof(*data)); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
269 if (!data) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
270 SDL_OutOfMemory(); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
271 return -1; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
272 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
273 data->pitch = (texture->w * SDL_BYTESPERPIXEL(texture->format)); |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
274 data->accelerated = 0; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
275 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
276 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
277 /* Use SDLs SW_YUVTexture */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
278 data->yuv = |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
279 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
280 if (!data->yuv) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
281 SDL_OutOfMemory(); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
282 return -1; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
283 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
284 /* but align pixels */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
285 SDL_free(data->yuv->pixels); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
286 data->yuv->pixels = (Uint8 *)memalign(16, texture->w * texture->h * 2); |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
287 if (!data->yuv->pixels) { |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
288 SDL_OutOfMemory(); |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
289 return -1; |
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
290 } |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
291 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
292 /* Redo: Find the pitch and offset values for the overlay */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
293 SDL_SW_YUVTexture *swdata = (SDL_SW_YUVTexture *) data->yuv; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
294 switch (texture->format) { |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
295 case SDL_PIXELFORMAT_YV12: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
296 case SDL_PIXELFORMAT_IYUV: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
297 swdata->pitches[0] = texture->w; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
298 swdata->pitches[1] = swdata->pitches[0] / 2; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
299 swdata->pitches[2] = swdata->pitches[0] / 2; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
300 swdata->planes[0] = swdata->pixels; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
301 swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * texture->h; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
302 swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * texture->h / 2; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
303 break; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
304 case SDL_PIXELFORMAT_YUY2: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
305 case SDL_PIXELFORMAT_UYVY: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
306 case SDL_PIXELFORMAT_YVYU: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
307 swdata->pitches[0] = texture->w * 2; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
308 swdata->planes[0] = swdata->pixels; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
309 break; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
310 default: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
311 /* We should never get here (caught above) */ |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
312 break; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
313 } |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
314 if ((texture->format & SDL_PIXELFORMAT_YV12 || texture->format & SDL_PIXELFORMAT_IYUV) |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
315 && texture->w % 16 == 0 && texture->h % 16 == 0) { |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
316 data->accelerated = 1; |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
317 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
318 } else { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
319 data->pixels = NULL; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
320 data->pixels = SDL_malloc(texture->h * data->pitch); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
321 if (!data->pixels) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
322 PS3_DestroyTexture(renderer, texture); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
323 SDL_OutOfMemory(); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
324 return -1; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
325 } |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
326 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
327 texture->driverdata = data; |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
328 deprintf(1, "-PS3_CreateTexture()\n"); |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
329 return 0; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
330 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
331 |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
332 static int |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
333 PS3_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
334 void **pixels, int *pitch) |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
335 { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
336 deprintf(1, "+PS3_QueryTexturePixels()\n"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
337 PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
338 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
339 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
340 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
341 } else { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
342 *pixels = (void *)data->pixels; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
343 *pitch = data->pitch; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
344 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
345 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
346 deprintf(1, "-PS3_QueryTexturePixels()\n"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
347 return 0; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
348 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
349 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
350 static int |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
351 PS3_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
352 const SDL_Rect * rect, const void *pixels, int pitch) |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
353 { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
354 deprintf(1, "+PS3_UpdateTexture()\n"); |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
355 PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
356 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
357 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
358 return SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
359 } else { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
360 Uint8 *src, *dst; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
361 int row; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
362 size_t length; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
363 Uint8 *dstpixels; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
364 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
365 src = (Uint8 *) pixels; |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
366 dst = (Uint8 *) dstpixels + rect->y * data->pitch + rect->x |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
367 * SDL_BYTESPERPIXEL(texture->format); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
368 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
369 for (row = 0; row < rect->h; ++row) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
370 SDL_memcpy(dst, src, length); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
371 src += pitch; |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
372 dst += data->pitch; |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
373 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
374 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
375 deprintf(1, "-PS3_UpdateTexture()\n"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
376 return 0; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
377 } |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
378 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
379 static int |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
380 PS3_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
381 const SDL_Rect * rect, int markDirty, void **pixels, |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
382 int *pitch) |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
383 { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
384 deprintf(1, "+PS3_LockTexture()\n"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
385 PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
386 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
387 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
388 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, pitch); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
389 } else { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
390 *pixels = |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
391 (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
392 rect->x * SDL_BYTESPERPIXEL(texture->format)); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
393 *pitch = data->pitch; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
394 return 0; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
395 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
396 deprintf(1, "-PS3_LockTexture()\n"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
397 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
398 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
399 static void |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
400 PS3_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
401 { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
402 deprintf(1, "+PS3_UnlockTexture()\n"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
403 PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
404 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
405 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
406 SDL_SW_UnlockYUVTexture(data->yuv); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
407 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
408 deprintf(1, "-PS3_UnlockTexture()\n"); |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
409 } |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
410 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
411 static void |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
412 PS3_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
413 { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
414 deprintf(1, "+PS3_DestroyTexture()\n"); |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
415 PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
416 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
417 if (!data) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
418 return; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
419 } |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
420 if (data->yuv) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
421 SDL_SW_DestroyYUVTexture(data->yuv); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
422 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
423 if (data->pixels) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
424 SDL_free((void *)data->pixels); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
425 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
426 deprintf(1, "-PS3_DestroyTexture()\n"); |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
427 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
428 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
429 static int |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
430 SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
431 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
432 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
433 (SDL_PS3_RenderData *) renderer->driverdata; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
434 SDL_Surface *target = data->screen; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
435 int status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
436 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
437 if (renderer->blendMode == SDL_BLENDMODE_NONE || |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
438 renderer->blendMode == SDL_BLENDMODE_MASK) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
439 Uint32 color = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
440 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
441 renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
442 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
443 status = SDL_DrawPoint(target, x, y, color); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
444 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
445 status = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
446 SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
447 renderer->g, renderer->b, renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
448 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
449 return status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
450 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
451 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
452 static int |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
453 SDL_PS3_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
454 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
455 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
456 (SDL_PS3_RenderData *) renderer->driverdata; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
457 SDL_Surface *target = data->screen; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
458 int status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
459 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
460 if (renderer->blendMode == SDL_BLENDMODE_NONE || |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
461 renderer->blendMode == SDL_BLENDMODE_MASK) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
462 Uint32 color = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
463 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
464 renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
465 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
466 status = SDL_DrawLine(target, x1, y1, x2, y2, color); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
467 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
468 status = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
469 SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
470 renderer->r, renderer->g, renderer->b, renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
471 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
472 return status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
473 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
474 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
475 static int |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
476 SDL_PS3_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
477 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
478 deprintf(1, "SDL_PS3_RenderFill()\n"); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
479 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
480 (SDL_PS3_RenderData *) renderer->driverdata; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
481 SDL_Surface *target = data->screen; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
482 SDL_Rect real_rect = *rect; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
483 int status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
484 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
485 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
486 Uint32 color = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
487 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
488 renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
489 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
490 status = SDL_FillRect(target, &real_rect, color); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
491 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
492 status = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
493 SDL_BlendRect(target, &real_rect, renderer->blendMode, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
494 renderer->r, renderer->g, renderer->b, renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
495 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
496 return status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
497 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
498 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
499 static int |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
500 SDL_PS3_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
501 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
502 { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
503 deprintf(1, "+SDL_PS3_RenderCopy()\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
504 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
505 (SDL_PS3_RenderData *) renderer->driverdata; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
506 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
507 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
508 PS3_TextureData *txdata = (PS3_TextureData *) texture->driverdata; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
509 SDL_VideoData *devdata = display->device->driverdata; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
510 |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
511 /* Debug info */ |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
512 deprintf(1, "srcrect->w = %u\n", srcrect->w); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
513 deprintf(1, "srcrect->h = %u\n", srcrect->h); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
514 deprintf(1, "srcrect->x = %u\n", srcrect->x); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
515 deprintf(1, "srcrect->y = %u\n", srcrect->y); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
516 deprintf(1, "dstrect->w = %u\n", dstrect->w); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
517 deprintf(1, "dstrect->h = %u\n", dstrect->h); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
518 deprintf(1, "dstrect->x = %u\n", dstrect->x); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
519 deprintf(1, "dstrect->y = %u\n", dstrect->y); |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
520 deprintf(1, "texture->w = %u\n", texture->w); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
521 deprintf(1, "texture->h = %u\n", texture->h); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
522 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
523 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
524 deprintf(1, "SDL_ISPIXELFORMAT_FOURCC = true\n"); |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
525 if (txdata->accelerated) { |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
526 deprintf(1, "Use SPE for scaling/converting\n"); |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
527 |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
528 SDL_SW_YUVTexture *swdata = (SDL_SW_YUVTexture *) txdata->yuv; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
529 Uint8 *lum, *Cr, *Cb; |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
530 Uint8 *scaler_out = NULL; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
531 Uint8 *dstpixels; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
532 switch (swdata->format) { |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
533 case SDL_PIXELFORMAT_YV12: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
534 lum = swdata->planes[0]; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
535 Cr = swdata->planes[1]; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
536 Cb = swdata->planes[2]; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
537 break; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
538 case SDL_PIXELFORMAT_IYUV: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
539 lum = swdata->planes[0]; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
540 Cr = swdata->planes[2]; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
541 Cb = swdata->planes[1]; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
542 break; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
543 default: |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
544 return -1; |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
545 } |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
546 |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
547 if (srcrect->w != dstrect->w || srcrect->h != dstrect->h) { |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
548 /* Alloc mem for scaled YUV picture */ |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
549 scaler_out = (Uint8 *) memalign(16, dstrect->w * dstrect->h + ((dstrect->w * dstrect->h) >> 1)); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
550 if (scaler_out == NULL) { |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
551 SDL_OutOfMemory(); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
552 return -1; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
553 } |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
554 |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
555 /* Set parms for scaling */ |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
556 data->scaler_parms->src_pixel_width = srcrect->w; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
557 data->scaler_parms->src_pixel_height = srcrect->h; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
558 data->scaler_parms->dst_pixel_width = dstrect->w; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
559 data->scaler_parms->dst_pixel_height = dstrect->h; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
560 data->scaler_parms->y_plane = lum; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
561 data->scaler_parms->v_plane = Cr; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
562 data->scaler_parms->u_plane = Cb; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
563 data->scaler_parms->dstBuffer = scaler_out; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
564 data->scaler_thread_data->argp = (void *)data->scaler_parms; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
565 |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
566 /* Scale the YUV overlay to given size */ |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
567 SPE_Start(data->scaler_thread_data); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
568 SPE_Stop(data->scaler_thread_data); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
569 |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
570 /* Set parms for converting after scaling */ |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
571 data->converter_parms->y_plane = scaler_out; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
572 data->converter_parms->v_plane = scaler_out + dstrect->w * dstrect->h; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
573 data->converter_parms->u_plane = scaler_out + dstrect->w * dstrect->h + ((dstrect->w * dstrect->h) >> 2); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
574 } else { |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
575 data->converter_parms->y_plane = lum; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
576 data->converter_parms->v_plane = Cr; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
577 data->converter_parms->u_plane = Cb; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
578 } |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
579 |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
580 dstpixels = (Uint8 *) data->screen->pixels + dstrect->y * data->screen->pitch + dstrect->x |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
581 * SDL_BYTESPERPIXEL(texture->format); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
582 data->converter_parms->src_pixel_width = dstrect->w; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
583 data->converter_parms->src_pixel_height = dstrect->h; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
584 data->converter_parms->dstBuffer = dstpixels/*(Uint8 *)data->screen->pixels*/; |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
585 data->converter_thread_data->argp = (void *)data->converter_parms; |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
586 |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
587 /* Convert YUV texture to RGB */ |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
588 SPE_SendMsg(data->converter_thread_data, SPU_START); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
589 SPE_SendMsg(data->converter_thread_data, (unsigned int)data->converter_thread_data->argp); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
590 |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
591 /* We can probably move that to RenderPresent() */ |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
592 SPE_WaitForMsg(data->converter_thread_data, SPU_FIN); |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
593 if (scaler_out) { |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
594 free(scaler_out); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
595 } |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
596 } else { |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
597 deprintf(1, "Use software for scaling/converting\n"); |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
598 Uint8 *dst; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
599 /* FIXME: Not good */ |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
600 dst = (Uint8 *) data->screen->pixels + dstrect->y * data->screen->pitch + dstrect->x |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
601 * SDL_BYTESPERPIXEL(texture->format); |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
602 return SDL_SW_CopyYUVToRGB(txdata->yuv, srcrect, display->current_mode.format, |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
603 dstrect->w, dstrect->h, dst/*data->screen->pixels*/, |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
604 data->screen->pitch); |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
605 } |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
606 } else { |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
607 deprintf(1, "SDL_ISPIXELFORMAT_FOURCC = false\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
608 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
609 Uint8 *src, *dst; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
610 int row; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
611 size_t length; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
612 Uint8 *dstpixels; |
3143
8fdabaa064c3
Fixed centering. Added debug msgs for RenderCopy().
Martin Lowinski <martin@goldtopf.org>
parents:
3142
diff
changeset
|
613 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
614 src = (Uint8 *) txdata->pixels; |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
615 dst = (Uint8 *) data->screen->pixels + dstrect->y * data->screen->pitch + dstrect->x |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
616 * SDL_BYTESPERPIXEL(texture->format); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
617 length = dstrect->w * SDL_BYTESPERPIXEL(texture->format); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
618 for (row = 0; row < dstrect->h; ++row) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
619 SDL_memcpy(dst, src, length); |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
620 src += txdata->pitch; |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
621 dst += data->screen->pitch; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
622 } |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
623 } |
3143
8fdabaa064c3
Fixed centering. Added debug msgs for RenderCopy().
Martin Lowinski <martin@goldtopf.org>
parents:
3142
diff
changeset
|
624 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
625 deprintf(1, "-SDL_PS3_RenderCopy()\n"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
626 return 0; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
627 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
628 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
629 static void |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
630 SDL_PS3_RenderPresent(SDL_Renderer * renderer) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
631 { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
632 deprintf(1, "+SDL_PS3_RenderPresent()\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
633 static int frame_number; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
634 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
635 (SDL_PS3_RenderData *) renderer->driverdata; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
636 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
637 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
638 SDL_VideoData *devdata = display->device->driverdata; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
639 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
640 /* Send the data to the screen */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
641 /* Get screeninfo */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
642 struct fb_fix_screeninfo fb_finfo; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
643 if (ioctl(devdata->fbdev, FBIOGET_FSCREENINFO, &fb_finfo)) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
644 SDL_SetError("[PS3] Can't get fixed screeninfo"); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
645 } |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
646 struct fb_var_screeninfo fb_vinfo; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
647 if (ioctl(devdata->fbdev, FBIOGET_VSCREENINFO, &fb_vinfo)) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
648 SDL_SetError("[PS3] Can't get VSCREENINFO"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
649 } |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
650 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
651 /* 16 and 15 bpp is reported as 16 bpp */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
652 //txdata->bpp = fb_vinfo.bits_per_pixel; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
653 //if (txdata->bpp == 16) |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
654 // txdata->bpp = fb_vinfo.red.length + fb_vinfo.green.length + fb_vinfo.blue.length; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
655 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
656 /* Adjust centering */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
657 data->bounded_width = window->w < fb_vinfo.xres ? window->w : fb_vinfo.xres; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
658 data->bounded_height = window->h < fb_vinfo.yres ? window->h : fb_vinfo.yres; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
659 data->offset_left = (fb_vinfo.xres - data->bounded_width) >> 1; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
660 data->offset_top = (fb_vinfo.yres - data->bounded_height) >> 1; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
661 data->center[0] = devdata->frame_buffer + data->offset_left * /*txdata->bpp/8*/ 4 + |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
662 data->offset_top * fb_finfo.line_length; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
663 data->center[1] = data->center[0] + fb_vinfo.yres * fb_finfo.line_length; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
664 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
665 deprintf(1, "offset_left = %u\n", data->offset_left); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
666 deprintf(1, "offset_top = %u\n", data->offset_top); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
667 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
668 /* Set SPU parms for copying the surface to framebuffer */ |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
669 devdata->fb_parms->data = (unsigned char *)data->screen->pixels; |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
670 devdata->fb_parms->center = data->center[data->current_screen]; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
671 devdata->fb_parms->out_line_stride = fb_finfo.line_length; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
672 devdata->fb_parms->in_line_stride = window->w * /*txdata->bpp / 8*/4; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
673 devdata->fb_parms->bounded_input_height = data->bounded_height; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
674 devdata->fb_parms->bounded_input_width = data->bounded_width; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
675 //devdata->fb_parms->fb_pixel_size = txdata->bpp / 8; |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
676 devdata->fb_parms->fb_pixel_size = 4;//SDL_BYTESPERPIXEL(window->format); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
677 |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
678 deprintf(3, "[PS3->SPU] fb_thread_data->argp = 0x%x\n", devdata->fb_thread_data->argp); |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
679 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
680 /* Copying.. */ |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
681 SPE_SendMsg(devdata->fb_thread_data, SPU_START); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
682 SPE_SendMsg(devdata->fb_thread_data, (unsigned int)devdata->fb_thread_data->argp); |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
683 |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
684 SPE_WaitForMsg(devdata->fb_thread_data, SPU_FIN); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
685 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
686 /* Wait for vsync */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
687 if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
688 unsigned long crt = 0; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
689 deprintf(1, "[PS3] Wait for vsync\n"); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
690 ioctl(devdata->fbdev, FBIO_WAITFORVSYNC, &crt); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
691 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
692 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
693 /* Page flip */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
694 deprintf(1, "[PS3] Page flip to buffer #%u 0x%x\n", data->current_screen, data->center[data->current_screen]); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
695 ioctl(devdata->fbdev, PS3FB_IOCTL_FSEL, (unsigned long)&data->current_screen); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
696 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
697 /* Update the flipping chain, if any */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
698 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2 && data->double_buffering) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
699 data->current_screen = (data->current_screen + 1) % 2; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
700 } |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
701 deprintf(1, "-SDL_PS3_RenderPresent()\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
702 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
703 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
704 static void |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
705 SDL_PS3_DestroyRenderer(SDL_Renderer * renderer) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
706 { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
707 deprintf(1, "+SDL_PS3_DestroyRenderer()\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
708 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
709 (SDL_PS3_RenderData *) renderer->driverdata; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
710 int i; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
711 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
712 if (data) { |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
713 for (i = 0; i < SDL_arraysize(data->screen); ++i) { |
3147
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
714 if (data->screen) { |
a80760096937
Support all YUV texture formats using SW_Textures.
Martin Lowinski <martin@goldtopf.org>
parents:
3146
diff
changeset
|
715 SDL_FreeSurface(data->screen); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
716 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
717 } |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
718 |
3150
0cf7bff804ad
Code reviewed and added SPE API documentation.
Martin Lowinski <martin@goldtopf.org>
parents:
3148
diff
changeset
|
719 /* Shutdown SPE and release related resources */ |
3148
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
720 if (data->scaler_thread_data) { |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
721 free((void *)data->scaler_thread_data); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
722 } |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
723 if (data->scaler_parms) { |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
724 free((void *)data->scaler_parms); |
104786a909a2
Scaling (bilinear) of YUV-Textures working.
Martin Lowinski <martin@goldtopf.org>
parents:
3147
diff
changeset
|
725 } |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
726 if (data->converter_thread_data) { |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
727 SPE_Shutdown(data->converter_thread_data); |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
728 free((void *)data->converter_thread_data); |
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
729 } |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
730 if (data->converter_parms) { |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
731 free((void *)data->converter_parms); |
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
732 } |
3144
0d8d1f870964
Moved SPE-functions to SDL_ps3spe.c.
Martin Lowinski <martin@goldtopf.org>
parents:
3143
diff
changeset
|
733 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
734 SDL_free(data); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
735 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
736 SDL_free(renderer); |
3146
9e902f423497
YUV-Textures with SPU-support working.
Martin Lowinski <martin@goldtopf.org>
parents:
3144
diff
changeset
|
737 deprintf(1, "-SDL_PS3_DestroyRenderer()\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
738 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
739 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
740 /* vi: set ts=4 sw=4 expandtab: */ |