disable float support on m68k to prevent unwanted symbols being used in rom code...
[AROS.git] / workbench / hidds / softpipe / softpipe_galliumclass.c
blob17ad1b379dc234cae1039bc13959ade223642d63
1 /*
2 Copyright © 2010-2018, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include <proto/oop.h>
9 #include <proto/cybergraphics.h>
10 #include <proto/graphics.h>
11 #include <proto/utility.h>
13 #include <cybergraphx/cybergraphics.h>
15 #include <hidd/gallium.h>
16 #include <gallium/gallium.h>
18 #include <gallium/pipe/p_screen.h>
19 #include "softpipe/sp_texture.h"
20 #include "softpipe/sp_public.h"
21 #include "softpipe/sp_screen.h"
22 #include "util/u_format.h"
23 #include "util/u_math.h"
24 #include "state_tracker/sw_winsys.h"
26 #include "softpipe_intern.h"
29 #if (AROS_BIG_ENDIAN == 1)
30 #define AROS_PIXFMT RECTFMT_RAW /* Big Endian Archs. */
31 #else
32 #define AROS_PIXFMT RECTFMT_BGRA32 /* Little Endian Archs. */
33 #endif
35 #define CyberGfxBase (&BASE(cl->UserData)->sd)->SoftpipeCyberGfxBase
37 #undef HiddGalliumAttrBase
38 #define HiddGalliumAttrBase (SD(cl)->hiddGalliumAB)
40 struct HiddSoftpipeWinSys
42 struct HIDDT_WinSys base;
43 struct sw_winsys swws;
46 /* Displaytarget support code */
47 struct HiddSoftpipeDisplaytarget
49 APTR data;
52 struct HiddSoftpipeDisplaytarget * HiddSoftpipeDisplaytarget(struct sw_displaytarget * dt)
54 return (struct HiddSoftpipeDisplaytarget *)dt;
57 static struct sw_displaytarget *
58 HiddSoftpipeCreateDisplaytarget(struct sw_winsys *winsys, unsigned tex_usage,
59 enum pipe_format format, unsigned width, unsigned height,
60 unsigned alignment, unsigned *stride)
62 struct HiddSoftpipeDisplaytarget * spdt =
63 AllocVec(sizeof(struct HiddSoftpipeDisplaytarget), MEMF_PUBLIC | MEMF_CLEAR);
65 *stride = align(util_format_get_stride(format, width), alignment);
66 spdt->data = AllocVec(*stride * height, MEMF_PUBLIC | MEMF_CLEAR);
68 return (struct sw_displaytarget *)spdt;
71 static void
72 HiddSoftpipeDestroyDisplaytarget(struct sw_winsys *ws, struct sw_displaytarget *dt)
74 struct HiddSoftpipeDisplaytarget * spdt = HiddSoftpipeDisplaytarget(dt);
76 if (spdt)
78 FreeVec(spdt->data);
79 FreeVec(spdt);
83 static void *
84 HiddSoftpipeMapDisplaytarget(struct sw_winsys *ws, struct sw_displaytarget *dt,
85 unsigned flags)
87 struct HiddSoftpipeDisplaytarget * spdt = HiddSoftpipeDisplaytarget(dt);
88 return spdt->data;
91 static void
92 HiddSoftpipeUnMapDisplaytarget(struct sw_winsys *ws, struct sw_displaytarget *dt)
94 /* No op */
97 /* Displaytarget support code ends */
99 static struct HiddSoftpipeWinSys *
100 HiddSoftpipeCreateSoftpipeWinSys(void)
102 struct HiddSoftpipeWinSys * ws = NULL;
104 ws = (struct HiddSoftpipeWinSys *)AllocVec
105 (sizeof(struct HiddSoftpipeWinSys), MEMF_PUBLIC|MEMF_CLEAR);
107 /* Fill in this struct with callbacks that pipe will need to
108 * communicate with the window system, buffer manager, etc.
111 /* Since Mesa 7.9 softpipe no longer uses pipe_winsys - it uses sw_winsys */
112 ws->base.base.buffer_create = NULL;
113 ws->base.base.user_buffer_create = NULL;
114 ws->base.base.buffer_map = NULL;
115 ws->base.base.buffer_unmap = NULL;
116 ws->base.base.buffer_destroy = NULL;
117 ws->base.base.surface_buffer_create = NULL;
118 ws->base.base.fence_reference = NULL;
119 ws->base.base.fence_signalled = NULL;
120 ws->base.base.fence_finish = NULL;
121 ws->base.base.flush_frontbuffer = NULL;
122 ws->base.base.get_name = NULL;
123 ws->base.base.destroy = NULL;
125 /* Fill in with functions is displaytarget is ever used*/
126 ws->swws.destroy = NULL;
127 ws->swws.is_displaytarget_format_supported = NULL;
128 ws->swws.displaytarget_create = HiddSoftpipeCreateDisplaytarget;
129 ws->swws.displaytarget_from_handle = NULL;
130 ws->swws.displaytarget_get_handle = NULL;
131 ws->swws.displaytarget_map = HiddSoftpipeMapDisplaytarget;
132 ws->swws.displaytarget_unmap = HiddSoftpipeUnMapDisplaytarget;
133 ws->swws.displaytarget_display = NULL;
134 ws->swws.displaytarget_destroy = HiddSoftpipeDestroyDisplaytarget;
136 return ws;
139 OOP_Object *METHOD(SoftpipeGallium, Root, New)
141 IPTR interfaceVers;
143 D(bug("[softpipe.hidd] %s()\n", __func__));
145 interfaceVers = GetTagData(aHidd_Gallium_InterfaceVersion, -1, msg->attrList);
146 if (interfaceVers != GALLIUM_INTERFACE_VERSION)
147 return NULL;
149 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
151 return o;
154 VOID METHOD(SoftpipeGallium, Root, Get)
156 ULONG idx;
158 if (IS_GALLIUM_ATTR(msg->attrID, idx))
160 switch (idx)
162 /* Overload the property */
163 case aoHidd_Gallium_InterfaceVersion:
164 *msg->storage = GALLIUM_INTERFACE_VERSION;
165 return;
169 /* Use parent class for all other properties */
170 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
173 APTR METHOD(SoftpipeGallium, Hidd_Gallium, CreatePipeScreen)
175 struct HiddSoftpipeWinSys * softpipews;
176 struct pipe_screen *screen;
178 softpipews = HiddSoftpipeCreateSoftpipeWinSys();
179 if (softpipews == NULL)
180 return NULL;
182 screen = softpipe_create_screen(&softpipews->swws);
183 if (screen == NULL)
184 goto fail;
186 /* Force a pipe_winsys pointer (Mesa 7.9 or never) */
187 screen->winsys = (struct pipe_winsys *)softpipews;
189 /* Preserve pointer to HIDD driver */
190 softpipews->base.driver = o;
192 return screen;
194 fail:
195 if (softpipews && softpipews->base.base.destroy)
196 softpipews->base.base.destroy((struct pipe_winsys *)softpipews);
198 return NULL;
201 VOID METHOD(SoftpipeGallium, Hidd_Gallium, DisplayResource)
203 struct softpipe_resource * spr = softpipe_resource(msg->resource);
204 struct sw_winsys * swws = softpipe_screen(spr->base.screen)->winsys;
205 struct RastPort * rp = CreateRastPort();
206 APTR * data = spr->data;
208 if ((data == NULL) && (spr->dt != NULL))
209 data = swws->displaytarget_map(swws, spr->dt, 0);
211 if (data)
213 rp->BitMap = msg->bitmap;
215 WritePixelArray(
216 data,
217 msg->srcx,
218 msg->srcy,
219 spr->stride[0],
220 rp,
221 msg->dstx,
222 msg->dsty,
223 msg->width,
224 msg->height,
225 AROS_PIXFMT);
228 if ((spr->data == NULL) && (data != NULL))
229 swws->displaytarget_unmap(swws, spr->dt);
231 FreeRastPort(rp);