lp_rast_priv.h revision 0a1c9001037a13b69b157994e7983aa3dee158d3
1ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca/************************************************************************** 2ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * 3ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * Copyright 2009 VMware, Inc. 4ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * All Rights Reserved. 5ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * 6ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * Permission is hereby granted, free of charge, to any person obtaining a 7ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * copy of this software and associated documentation files (the 8ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * "Software"), to deal in the Software without restriction, including 9ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * without limitation the rights to use, copy, modify, merge, publish, 10ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * distribute, sub license, and/or sell copies of the Software, and to 11ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * permit persons to whom the Software is furnished to do so, subject to 12ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * the following conditions: 13ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * 14ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * The above copyright notice and this permission notice (including the 15ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * next paragraph) shall be included in all copies or substantial portions 16ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * of the Software. 17ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * 18ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca * 26ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca **************************************************************************/ 27ee3383bc5ab81ff12d9faa675c1c38683300ce68José Fonseca 28e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell#ifndef LP_RAST_PRIV_H 29e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell#define LP_RAST_PRIV_H 30e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell 31a1af8eec66c5f7ec421e8011b41c1a7c36319f9fJosé Fonseca#include "os/os_thread.h" 325e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca#include "util/u_format.h" 335e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca#include "gallivm/lp_bld_debug.h" 342b3e1ad731d2bd095a680d3120619972a7eb0242Brian Paul#include "lp_memory.h" 35e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell#include "lp_rast.h" 360639765b2850739af1678f10fc0c5706d5827776Brian Paul#include "lp_scene.h" 374c4f98c6fcabc4a2c9ede3647de390a4585cf58aJosé Fonseca#include "lp_state.h" 380639765b2850739af1678f10fc0c5706d5827776Brian Paul#include "lp_texture.h" 392797f2bf57562c95a601a67edca3089641215cc4Brian Paul#include "lp_tile_soa.h" 4039be50dcdebe6bcbb48cb6aa8ac151eee811acb1José Fonseca#include "lp_limits.h" 413a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 423a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 436c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul/* If we crash in a jitted function, we can examine jit_line and jit_state 446c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul * to get some info. This is not thread-safe, however. 456c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul */ 466c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul#ifdef DEBUG 476c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 486c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paulextern int jit_line; 496c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paulextern const struct lp_rast_state *jit_state; 506c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 516c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul#define BEGIN_JIT_CALL(state) \ 526c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul do { \ 536c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul jit_line = __LINE__; \ 546c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul jit_state = state; \ 556c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul } while (0) 566c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 576c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul#define END_JIT_CALL() \ 586c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul do { \ 596c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul jit_line = 0; \ 606c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul jit_state = NULL; \ 616c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul } while (0) 626c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 636c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul#else 646c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 656c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul#define BEGIN_JIT_CALL(X) 66e75da1a8d668aa2a245a7c2690b42ae7a6038f48Brian Paul#define END_JIT_CALL() 676c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 686c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul#endif 696c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 706c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul 71aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paulstruct lp_rasterizer; 729f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellstruct cmd_bin; 73a9be9cd8be0fac4be5d65430749666d2204b79a4Brian Paul 74a9be9cd8be0fac4be5d65430749666d2204b79a4Brian Paul/** 753a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul * Per-thread rasterization state 76a9be9cd8be0fac4be5d65430749666d2204b79a4Brian Paul */ 773a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paulstruct lp_rasterizer_task 78a9be9cd8be0fac4be5d65430749666d2204b79a4Brian Paul{ 799f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const struct cmd_bin *bin; 804195febeecd2d2f5571afdb90cbb185a4759f50aKeith Whitwell const struct lp_rast_state *state; 819f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell 829f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell struct lp_scene *scene; 83a9be9cd8be0fac4be5d65430749666d2204b79a4Brian Paul unsigned x, y; /**< Pos of this tile in framebuffer, in pixels */ 843a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 850639765b2850739af1678f10fc0c5706d5827776Brian Paul uint8_t *color_tiles[PIPE_MAX_COLOR_BUFS]; 860639765b2850739af1678f10fc0c5706d5827776Brian Paul uint8_t *depth_tile; 870639765b2850739af1678f10fc0c5706d5827776Brian Paul 88aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul /** "back" pointer */ 89aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul struct lp_rasterizer *rast; 90aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 91aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul /** "my" index */ 92aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul unsigned thread_index; 93aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 9486afe8250edaa2e6129c937a62a695f616c48d70Qicheng Christopher Li /* occlude counter for visiable pixels */ 9586afe8250edaa2e6129c937a62a695f616c48d70Qicheng Christopher Li uint32_t vis_counter; 9618452c1e87f79327fbd5f27478028b481ee72a5dKeith Whitwell struct llvmpipe_query *query; 9786afe8250edaa2e6129c937a62a695f616c48d70Qicheng Christopher Li 98aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul pipe_semaphore work_ready; 99aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul pipe_semaphore work_done; 1003a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul}; 1013a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 1023a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 1033a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul/** 1043a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul * This is the state required while rasterizing tiles. 1053a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul * Note that this contains per-thread information too. 1063a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul * The tile size is TILE_SIZE x TILE_SIZE pixels. 1073a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul */ 1083a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paulstruct lp_rasterizer 1093a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul{ 110bc04ae21c10bedcc75d3483784d3eaf7bf090f55Brian Paul boolean exit_flag; 111e0e2008f1dcd73a59a184e0ef4c1dd77ac2a1cbfKeith Whitwell 112663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell /** The incoming queue of scenes ready to rasterize */ 113663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell struct lp_scene_queue *full_scenes; 1145fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 115663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell /** The scene currently being rasterized by the threads */ 116663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell struct lp_scene *curr_scene; 1172bce5c195f94e2cce8f67c6a8066b0ae408487ceBrian Paul 1183a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul /** A task object for each rasterization thread */ 11939be50dcdebe6bcbb48cb6aa8ac151eee811acb1José Fonseca struct lp_rasterizer_task tasks[LP_MAX_THREADS]; 120aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 121aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul unsigned num_threads; 12239be50dcdebe6bcbb48cb6aa8ac151eee811acb1José Fonseca pipe_thread threads[LP_MAX_THREADS]; 123aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 1242bce5c195f94e2cce8f67c6a8066b0ae408487ceBrian Paul /** For synchronizing the rasterization threads */ 1252bce5c195f94e2cce8f67c6a8066b0ae408487ceBrian Paul pipe_barrier barrier; 126e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell}; 127e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell 128ab76b2a8b896edc1e972de108d044b70310b4324José Fonseca 129d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwellvoid 130d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwelllp_rast_shade_quads_mask(struct lp_rasterizer_task *task, 131d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell const struct lp_rast_shader_inputs *inputs, 132d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell unsigned x, unsigned y, 133d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell unsigned mask); 134d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 135ab76b2a8b896edc1e972de108d044b70310b4324José Fonseca 1362797f2bf57562c95a601a67edca3089641215cc4Brian Paul 1372797f2bf57562c95a601a67edca3089641215cc4Brian Paul/** 1380639765b2850739af1678f10fc0c5706d5827776Brian Paul * Get the pointer to a 4x4 depth/stencil block. 1390639765b2850739af1678f10fc0c5706d5827776Brian Paul * We'll map the z/stencil buffer on demand here. 1400639765b2850739af1678f10fc0c5706d5827776Brian Paul * Note that this may be called even when there's no z/stencil buffer - return 1410639765b2850739af1678f10fc0c5706d5827776Brian Paul * NULL in that case. 1425e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca * \param x, y location of 4x4 block in window coords 1435e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca */ 1445e6a9005100ec2636ce9734a5e4535216494cf60José Fonsecastatic INLINE void * 1452b3e1ad731d2bd095a680d3120619972a7eb0242Brian Paullp_rast_get_depth_block_pointer(struct lp_rasterizer_task *task, 1460639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned x, unsigned y) 1475e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca{ 1489f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const struct lp_scene *scene = task->scene; 1490639765b2850739af1678f10fc0c5706d5827776Brian Paul void *depth; 1505fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1515e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca assert((x % TILE_VECTOR_WIDTH) == 0); 1525e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca assert((y % TILE_VECTOR_HEIGHT) == 0); 1535fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1549f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell if (!scene->zsbuf.map) { 155e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell /* Either out of memory or no zsbuf. Can't tell without access 156e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell * to the state. Just use dummy tile memory, but don't print 157e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell * the oom warning as this most likely because there is no 158e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell * zsbuf. 159e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell */ 1602f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell return lp_dummy_tile; 1612b3e1ad731d2bd095a680d3120619972a7eb0242Brian Paul } 1625fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1639f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell depth = (scene->zsbuf.map + 1649f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell scene->zsbuf.stride * y + 1659f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell scene->zsbuf.blocksize * x * TILE_VECTOR_HEIGHT); 1665fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1675e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca assert(lp_check_alignment(depth, 16)); 1685e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca return depth; 1695e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca} 1705e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca 1715e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca 1720639765b2850739af1678f10fc0c5706d5827776Brian Paul/** 173d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell * Get pointer to the swizzled color tile 174d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell */ 175d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwellstatic INLINE uint8_t * 176d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwelllp_rast_get_color_tile_pointer(struct lp_rasterizer_task *task, 177d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell unsigned buf, enum lp_texture_usage usage) 178d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell{ 1799f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const struct lp_scene *scene = task->scene; 180d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 181d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell assert(task->x % TILE_SIZE == 0); 182d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell assert(task->y % TILE_SIZE == 0); 1839f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell assert(buf < scene->fb.nr_cbufs); 184d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 185d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell if (!task->color_tiles[buf]) { 1869f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell struct pipe_surface *cbuf = scene->fb.cbufs[buf]; 187d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell struct llvmpipe_resource *lpt; 188d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell assert(cbuf); 189d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell lpt = llvmpipe_resource(cbuf->texture); 1902f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell task->color_tiles[buf] = lp_swizzled_cbuf[task->thread_index][buf]; 1912f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell 1922f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell if (usage != LP_TEX_USAGE_WRITE_ALL) { 1932f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell llvmpipe_swizzle_cbuf_tile(lpt, 1942f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell cbuf->face + cbuf->zslice, 1952f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell cbuf->level, 1962f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell task->x, task->y, 1972f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell task->color_tiles[buf]); 198d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell } 199d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell } 200d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 201d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell return task->color_tiles[buf]; 202d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell} 203d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 204d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 205d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell/** 2060639765b2850739af1678f10fc0c5706d5827776Brian Paul * Get the pointer to a 4x4 color block (within a 64x64 tile). 2070639765b2850739af1678f10fc0c5706d5827776Brian Paul * We'll map the color buffer on demand here. 2080639765b2850739af1678f10fc0c5706d5827776Brian Paul * Note that this may be called even when there's no color buffers - return 2090639765b2850739af1678f10fc0c5706d5827776Brian Paul * NULL in that case. 2100639765b2850739af1678f10fc0c5706d5827776Brian Paul * \param x, y location of 4x4 block in window coords 2110639765b2850739af1678f10fc0c5706d5827776Brian Paul */ 2120639765b2850739af1678f10fc0c5706d5827776Brian Paulstatic INLINE uint8_t * 2130639765b2850739af1678f10fc0c5706d5827776Brian Paullp_rast_get_color_block_pointer(struct lp_rasterizer_task *task, 2140639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned buf, unsigned x, unsigned y) 2150639765b2850739af1678f10fc0c5706d5827776Brian Paul{ 2160639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned px, py, pixel_offset; 2170639765b2850739af1678f10fc0c5706d5827776Brian Paul uint8_t *color; 2180639765b2850739af1678f10fc0c5706d5827776Brian Paul 2190639765b2850739af1678f10fc0c5706d5827776Brian Paul assert((x % TILE_VECTOR_WIDTH) == 0); 2200639765b2850739af1678f10fc0c5706d5827776Brian Paul assert((y % TILE_VECTOR_HEIGHT) == 0); 2210639765b2850739af1678f10fc0c5706d5827776Brian Paul 222d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell color = lp_rast_get_color_tile_pointer(task, buf, LP_TEX_USAGE_READ_WRITE); 2232f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell assert(color); 2240639765b2850739af1678f10fc0c5706d5827776Brian Paul 2250639765b2850739af1678f10fc0c5706d5827776Brian Paul px = x % TILE_SIZE; 2260639765b2850739af1678f10fc0c5706d5827776Brian Paul py = y % TILE_SIZE; 2270639765b2850739af1678f10fc0c5706d5827776Brian Paul pixel_offset = tile_pixel_offset(px, py, 0); 2280639765b2850739af1678f10fc0c5706d5827776Brian Paul 2290639765b2850739af1678f10fc0c5706d5827776Brian Paul color = color + pixel_offset; 2300639765b2850739af1678f10fc0c5706d5827776Brian Paul 2310639765b2850739af1678f10fc0c5706d5827776Brian Paul assert(lp_check_alignment(color, 16)); 2320639765b2850739af1678f10fc0c5706d5827776Brian Paul return color; 2330639765b2850739af1678f10fc0c5706d5827776Brian Paul} 2340639765b2850739af1678f10fc0c5706d5827776Brian Paul 2350639765b2850739af1678f10fc0c5706d5827776Brian Paul 2365e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca 2375e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca/** 2382797f2bf57562c95a601a67edca3089641215cc4Brian Paul * Shade all pixels in a 4x4 block. The fragment code omits the 2392797f2bf57562c95a601a67edca3089641215cc4Brian Paul * triangle in/out tests. 2402797f2bf57562c95a601a67edca3089641215cc4Brian Paul * \param x, y location of 4x4 block in window coords 2412797f2bf57562c95a601a67edca3089641215cc4Brian Paul */ 2422797f2bf57562c95a601a67edca3089641215cc4Brian Paulstatic INLINE void 2431c9db3c57f1538e21b839df0989b958be3465a36Brian Paullp_rast_shade_quads_all( struct lp_rasterizer_task *task, 2442797f2bf57562c95a601a67edca3089641215cc4Brian Paul const struct lp_rast_shader_inputs *inputs, 2452797f2bf57562c95a601a67edca3089641215cc4Brian Paul unsigned x, unsigned y ) 2462797f2bf57562c95a601a67edca3089641215cc4Brian Paul{ 2479f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const struct lp_scene *scene = task->scene; 2484195febeecd2d2f5571afdb90cbb185a4759f50aKeith Whitwell const struct lp_rast_state *state = task->state; 24918fb9ff6d8f58a08e559070cf29f26ed0caa567fJosé Fonseca struct lp_fragment_shader_variant *variant = state->variant; 2502797f2bf57562c95a601a67edca3089641215cc4Brian Paul uint8_t *color[PIPE_MAX_COLOR_BUFS]; 2512797f2bf57562c95a601a67edca3089641215cc4Brian Paul void *depth; 2520639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned i; 2532797f2bf57562c95a601a67edca3089641215cc4Brian Paul 2542797f2bf57562c95a601a67edca3089641215cc4Brian Paul /* color buffer */ 2559f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell for (i = 0; i < scene->fb.nr_cbufs; i++) 2560639765b2850739af1678f10fc0c5706d5827776Brian Paul color[i] = lp_rast_get_color_block_pointer(task, i, x, y); 2570639765b2850739af1678f10fc0c5706d5827776Brian Paul 2582b3e1ad731d2bd095a680d3120619972a7eb0242Brian Paul depth = lp_rast_get_depth_block_pointer(task, x, y); 2590639765b2850739af1678f10fc0c5706d5827776Brian Paul 2600639765b2850739af1678f10fc0c5706d5827776Brian Paul /* run shader on 4x4 block */ 2616c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul BEGIN_JIT_CALL(state); 26218fb9ff6d8f58a08e559070cf29f26ed0caa567fJosé Fonseca variant->jit_function[RAST_WHOLE]( &state->jit_context, 263d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell x, y, 2640a1c9001037a13b69b157994e7983aa3dee158d3Keith Whitwell inputs->frontfacing, 265d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell inputs->a0, 266d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell inputs->dadx, 267d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell inputs->dady, 268d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell color, 269d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell depth, 270d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 0xffff, 271d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell &task->vis_counter ); 2726c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul END_JIT_CALL(); 2732797f2bf57562c95a601a67edca3089641215cc4Brian Paul} 2742797f2bf57562c95a601a67edca3089641215cc4Brian Paul 2759f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_1( struct lp_rasterizer_task *, 2769f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2779f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_2( struct lp_rasterizer_task *, 2789f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2799f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_3( struct lp_rasterizer_task *, 2809f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2819f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_4( struct lp_rasterizer_task *, 2829f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2839f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_5( struct lp_rasterizer_task *, 2849f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2859f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_6( struct lp_rasterizer_task *, 2869f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2879f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_7( struct lp_rasterizer_task *, 2889f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2899f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_8( struct lp_rasterizer_task *, 2909f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2919f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell 292c4046d4fda2fe838659bff99bfa17f57f895a943Keith Whitwellvoid lp_rast_triangle_3_4(struct lp_rasterizer_task *, 293c4046d4fda2fe838659bff99bfa17f57f895a943Keith Whitwell const union lp_rast_cmd_arg ); 294c4046d4fda2fe838659bff99bfa17f57f895a943Keith Whitwell 2959f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_3_16( struct lp_rasterizer_task *, 2969f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2970ff132e5a633170afaed0aea54d01438c895b8abKeith Whitwell 2980ff132e5a633170afaed0aea54d01438c895b8abKeith Whitwellvoid lp_rast_triangle_4_16( struct lp_rasterizer_task *, 2990ff132e5a633170afaed0aea54d01438c895b8abKeith Whitwell const union lp_rast_cmd_arg ); 3000ff132e5a633170afaed0aea54d01438c895b8abKeith Whitwell 301f25836d7b2c21e046a725cf13c8649d3981693b7Keith Whitwellvoid 3024195febeecd2d2f5571afdb90cbb185a4759f50aKeith Whitwelllp_rast_set_state(struct lp_rasterizer_task *task, 3034195febeecd2d2f5571afdb90cbb185a4759f50aKeith Whitwell const union lp_rast_cmd_arg arg); 3044195febeecd2d2f5571afdb90cbb185a4759f50aKeith Whitwell 3054195febeecd2d2f5571afdb90cbb185a4759f50aKeith Whitwellvoid 306f25836d7b2c21e046a725cf13c8649d3981693b7Keith Whitwelllp_debug_bin( const struct cmd_bin *bin ); 3072797f2bf57562c95a601a67edca3089641215cc4Brian Paul 308e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell#endif 309