lp_rast_priv.h revision c4046d4fda2fe838659bff99bfa17f57f895a943
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; 809f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell 819f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell struct lp_scene *scene; 82a9be9cd8be0fac4be5d65430749666d2204b79a4Brian Paul unsigned x, y; /**< Pos of this tile in framebuffer, in pixels */ 833a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 840639765b2850739af1678f10fc0c5706d5827776Brian Paul uint8_t *color_tiles[PIPE_MAX_COLOR_BUFS]; 850639765b2850739af1678f10fc0c5706d5827776Brian Paul uint8_t *depth_tile; 860639765b2850739af1678f10fc0c5706d5827776Brian Paul 87aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul /** "back" pointer */ 88aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul struct lp_rasterizer *rast; 89aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 90aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul /** "my" index */ 91aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul unsigned thread_index; 92aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 9386afe8250edaa2e6129c937a62a695f616c48d70Qicheng Christopher Li /* occlude counter for visiable pixels */ 9486afe8250edaa2e6129c937a62a695f616c48d70Qicheng Christopher Li uint32_t vis_counter; 9518452c1e87f79327fbd5f27478028b481ee72a5dKeith Whitwell struct llvmpipe_query *query; 9686afe8250edaa2e6129c937a62a695f616c48d70Qicheng Christopher Li 97aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul pipe_semaphore work_ready; 98aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul pipe_semaphore work_done; 993a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul}; 1003a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 1013a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul 1023a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul/** 1033a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul * This is the state required while rasterizing tiles. 1043a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul * Note that this contains per-thread information too. 1053a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul * The tile size is TILE_SIZE x TILE_SIZE pixels. 1063a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul */ 1073a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paulstruct lp_rasterizer 1083a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul{ 109bc04ae21c10bedcc75d3483784d3eaf7bf090f55Brian Paul boolean exit_flag; 110e0e2008f1dcd73a59a184e0ef4c1dd77ac2a1cbfKeith Whitwell 111663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell /** The incoming queue of scenes ready to rasterize */ 112663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell struct lp_scene_queue *full_scenes; 1135fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 114663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell /** The scene currently being rasterized by the threads */ 115663750d5564a225b4720f7ee8bea93ffb309fc88Keith Whitwell struct lp_scene *curr_scene; 1162bce5c195f94e2cce8f67c6a8066b0ae408487ceBrian Paul 1173a06c113c76355fc9622adfe7565c18d9787e9a8Brian Paul /** A task object for each rasterization thread */ 11839be50dcdebe6bcbb48cb6aa8ac151eee811acb1José Fonseca struct lp_rasterizer_task tasks[LP_MAX_THREADS]; 119aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 120aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul unsigned num_threads; 12139be50dcdebe6bcbb48cb6aa8ac151eee811acb1José Fonseca pipe_thread threads[LP_MAX_THREADS]; 122aab1ceceecbd6449eebce7f5f5b356b1a51552e7Brian Paul 1232bce5c195f94e2cce8f67c6a8066b0ae408487ceBrian Paul /** For synchronizing the rasterization threads */ 1242bce5c195f94e2cce8f67c6a8066b0ae408487ceBrian Paul pipe_barrier barrier; 125e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell}; 126e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell 127ab76b2a8b896edc1e972de108d044b70310b4324José Fonseca 128d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwellvoid 129d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwelllp_rast_shade_quads_mask(struct lp_rasterizer_task *task, 130d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell const struct lp_rast_shader_inputs *inputs, 131d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell unsigned x, unsigned y, 132d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell unsigned mask); 133d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 134ab76b2a8b896edc1e972de108d044b70310b4324José Fonseca 1352797f2bf57562c95a601a67edca3089641215cc4Brian Paul 1362797f2bf57562c95a601a67edca3089641215cc4Brian Paul/** 1370639765b2850739af1678f10fc0c5706d5827776Brian Paul * Get the pointer to a 4x4 depth/stencil block. 1380639765b2850739af1678f10fc0c5706d5827776Brian Paul * We'll map the z/stencil buffer on demand here. 1390639765b2850739af1678f10fc0c5706d5827776Brian Paul * Note that this may be called even when there's no z/stencil buffer - return 1400639765b2850739af1678f10fc0c5706d5827776Brian Paul * NULL in that case. 1415e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca * \param x, y location of 4x4 block in window coords 1425e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca */ 1435e6a9005100ec2636ce9734a5e4535216494cf60José Fonsecastatic INLINE void * 1442b3e1ad731d2bd095a680d3120619972a7eb0242Brian Paullp_rast_get_depth_block_pointer(struct lp_rasterizer_task *task, 1450639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned x, unsigned y) 1465e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca{ 1479f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const struct lp_scene *scene = task->scene; 1480639765b2850739af1678f10fc0c5706d5827776Brian Paul void *depth; 1495fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1505e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca assert((x % TILE_VECTOR_WIDTH) == 0); 1515e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca assert((y % TILE_VECTOR_HEIGHT) == 0); 1525fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1539f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell if (!scene->zsbuf.map) { 154e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell /* Either out of memory or no zsbuf. Can't tell without access 155e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell * to the state. Just use dummy tile memory, but don't print 156e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell * the oom warning as this most likely because there is no 157e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell * zsbuf. 158e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell */ 1592f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell return lp_dummy_tile; 1602b3e1ad731d2bd095a680d3120619972a7eb0242Brian Paul } 1615fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1629f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell depth = (scene->zsbuf.map + 1639f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell scene->zsbuf.stride * y + 1649f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell scene->zsbuf.blocksize * x * TILE_VECTOR_HEIGHT); 1655fe2ce28b6e9fba181c13c6f49b57b3dd68fe88eKeith Whitwell 1665e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca assert(lp_check_alignment(depth, 16)); 1675e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca return depth; 1685e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca} 1695e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca 1705e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca 1710639765b2850739af1678f10fc0c5706d5827776Brian Paul/** 172d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell * Get pointer to the swizzled color tile 173d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell */ 174d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwellstatic INLINE uint8_t * 175d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwelllp_rast_get_color_tile_pointer(struct lp_rasterizer_task *task, 176d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell unsigned buf, enum lp_texture_usage usage) 177d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell{ 1789f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const struct lp_scene *scene = task->scene; 179d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 180d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell assert(task->x % TILE_SIZE == 0); 181d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell assert(task->y % TILE_SIZE == 0); 1829f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell assert(buf < scene->fb.nr_cbufs); 183d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 184d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell if (!task->color_tiles[buf]) { 1859f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell struct pipe_surface *cbuf = scene->fb.cbufs[buf]; 186d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell struct llvmpipe_resource *lpt; 187d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell assert(cbuf); 188d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell lpt = llvmpipe_resource(cbuf->texture); 1892f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell task->color_tiles[buf] = lp_swizzled_cbuf[task->thread_index][buf]; 1902f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell 1912f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell if (usage != LP_TEX_USAGE_WRITE_ALL) { 1922f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell llvmpipe_swizzle_cbuf_tile(lpt, 1932f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell cbuf->face + cbuf->zslice, 1942f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell cbuf->level, 1952f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell task->x, task->y, 1962f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell task->color_tiles[buf]); 197d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell } 198d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell } 199d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 200d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell return task->color_tiles[buf]; 201d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell} 202d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 203d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 204d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell/** 2050639765b2850739af1678f10fc0c5706d5827776Brian Paul * Get the pointer to a 4x4 color block (within a 64x64 tile). 2060639765b2850739af1678f10fc0c5706d5827776Brian Paul * We'll map the color buffer on demand here. 2070639765b2850739af1678f10fc0c5706d5827776Brian Paul * Note that this may be called even when there's no color buffers - return 2080639765b2850739af1678f10fc0c5706d5827776Brian Paul * NULL in that case. 2090639765b2850739af1678f10fc0c5706d5827776Brian Paul * \param x, y location of 4x4 block in window coords 2100639765b2850739af1678f10fc0c5706d5827776Brian Paul */ 2110639765b2850739af1678f10fc0c5706d5827776Brian Paulstatic INLINE uint8_t * 2120639765b2850739af1678f10fc0c5706d5827776Brian Paullp_rast_get_color_block_pointer(struct lp_rasterizer_task *task, 2130639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned buf, unsigned x, unsigned y) 2140639765b2850739af1678f10fc0c5706d5827776Brian Paul{ 2150639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned px, py, pixel_offset; 2160639765b2850739af1678f10fc0c5706d5827776Brian Paul uint8_t *color; 2170639765b2850739af1678f10fc0c5706d5827776Brian Paul 2180639765b2850739af1678f10fc0c5706d5827776Brian Paul assert((x % TILE_VECTOR_WIDTH) == 0); 2190639765b2850739af1678f10fc0c5706d5827776Brian Paul assert((y % TILE_VECTOR_HEIGHT) == 0); 2200639765b2850739af1678f10fc0c5706d5827776Brian Paul 221d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell color = lp_rast_get_color_tile_pointer(task, buf, LP_TEX_USAGE_READ_WRITE); 2222f6d47a7c8d6e69e5154de44115aab9ba35a41d2Keith Whitwell assert(color); 2230639765b2850739af1678f10fc0c5706d5827776Brian Paul 2240639765b2850739af1678f10fc0c5706d5827776Brian Paul px = x % TILE_SIZE; 2250639765b2850739af1678f10fc0c5706d5827776Brian Paul py = y % TILE_SIZE; 2260639765b2850739af1678f10fc0c5706d5827776Brian Paul pixel_offset = tile_pixel_offset(px, py, 0); 2270639765b2850739af1678f10fc0c5706d5827776Brian Paul 2280639765b2850739af1678f10fc0c5706d5827776Brian Paul color = color + pixel_offset; 2290639765b2850739af1678f10fc0c5706d5827776Brian Paul 2300639765b2850739af1678f10fc0c5706d5827776Brian Paul assert(lp_check_alignment(color, 16)); 2310639765b2850739af1678f10fc0c5706d5827776Brian Paul return color; 2320639765b2850739af1678f10fc0c5706d5827776Brian Paul} 2330639765b2850739af1678f10fc0c5706d5827776Brian Paul 2340639765b2850739af1678f10fc0c5706d5827776Brian Paul 2355e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca 2365e6a9005100ec2636ce9734a5e4535216494cf60José Fonseca/** 2372797f2bf57562c95a601a67edca3089641215cc4Brian Paul * Shade all pixels in a 4x4 block. The fragment code omits the 2382797f2bf57562c95a601a67edca3089641215cc4Brian Paul * triangle in/out tests. 2392797f2bf57562c95a601a67edca3089641215cc4Brian Paul * \param x, y location of 4x4 block in window coords 2402797f2bf57562c95a601a67edca3089641215cc4Brian Paul */ 2412797f2bf57562c95a601a67edca3089641215cc4Brian Paulstatic INLINE void 2421c9db3c57f1538e21b839df0989b958be3465a36Brian Paullp_rast_shade_quads_all( struct lp_rasterizer_task *task, 2432797f2bf57562c95a601a67edca3089641215cc4Brian Paul const struct lp_rast_shader_inputs *inputs, 2442797f2bf57562c95a601a67edca3089641215cc4Brian Paul unsigned x, unsigned y ) 2452797f2bf57562c95a601a67edca3089641215cc4Brian Paul{ 2469f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const struct lp_scene *scene = task->scene; 247e21e7ab4da859198dfa9845b4a7207c49db54771Keith Whitwell const struct lp_rast_state *state = inputs->state; 24818fb9ff6d8f58a08e559070cf29f26ed0caa567fJosé Fonseca struct lp_fragment_shader_variant *variant = state->variant; 2492797f2bf57562c95a601a67edca3089641215cc4Brian Paul uint8_t *color[PIPE_MAX_COLOR_BUFS]; 2502797f2bf57562c95a601a67edca3089641215cc4Brian Paul void *depth; 2510639765b2850739af1678f10fc0c5706d5827776Brian Paul unsigned i; 2522797f2bf57562c95a601a67edca3089641215cc4Brian Paul 2532797f2bf57562c95a601a67edca3089641215cc4Brian Paul /* color buffer */ 2549f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell for (i = 0; i < scene->fb.nr_cbufs; i++) 2550639765b2850739af1678f10fc0c5706d5827776Brian Paul color[i] = lp_rast_get_color_block_pointer(task, i, x, y); 2560639765b2850739af1678f10fc0c5706d5827776Brian Paul 2572b3e1ad731d2bd095a680d3120619972a7eb0242Brian Paul depth = lp_rast_get_depth_block_pointer(task, x, y); 2580639765b2850739af1678f10fc0c5706d5827776Brian Paul 2590639765b2850739af1678f10fc0c5706d5827776Brian Paul /* run shader on 4x4 block */ 2606c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul BEGIN_JIT_CALL(state); 26118fb9ff6d8f58a08e559070cf29f26ed0caa567fJosé Fonseca variant->jit_function[RAST_WHOLE]( &state->jit_context, 262d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell x, y, 263d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell inputs->facing, 264d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell inputs->a0, 265d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell inputs->dadx, 266d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell inputs->dady, 267d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell color, 268d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell depth, 269d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell 0xffff, 270d4b64167b56f780d0dea73193c345622888fbc16Keith Whitwell &task->vis_counter ); 2716c1625cc405f0d77523c122cedf3e8003f2aa7bfBrian Paul END_JIT_CALL(); 2722797f2bf57562c95a601a67edca3089641215cc4Brian Paul} 2732797f2bf57562c95a601a67edca3089641215cc4Brian Paul 2749f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_1( struct lp_rasterizer_task *, 2759f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2769f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_2( struct lp_rasterizer_task *, 2779f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2789f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_3( struct lp_rasterizer_task *, 2799f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2809f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_4( struct lp_rasterizer_task *, 2819f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2829f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_5( struct lp_rasterizer_task *, 2839f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2849f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_6( struct lp_rasterizer_task *, 2859f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2869f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_7( struct lp_rasterizer_task *, 2879f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2889f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_8( struct lp_rasterizer_task *, 2899f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 2909f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell 291c4046d4fda2fe838659bff99bfa17f57f895a943Keith Whitwellvoid lp_rast_triangle_3_4(struct lp_rasterizer_task *, 292c4046d4fda2fe838659bff99bfa17f57f895a943Keith Whitwell const union lp_rast_cmd_arg ); 293c4046d4fda2fe838659bff99bfa17f57f895a943Keith Whitwell 2949f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwellvoid lp_rast_triangle_3_16( struct lp_rasterizer_task *, 2959f6e8e1d6b8696a3ee96cba01b2466ba7a1a8ef6Keith Whitwell const union lp_rast_cmd_arg ); 296f25836d7b2c21e046a725cf13c8649d3981693b7Keith Whitwellvoid 297f25836d7b2c21e046a725cf13c8649d3981693b7Keith Whitwelllp_debug_bin( const struct cmd_bin *bin ); 2982797f2bf57562c95a601a67edca3089641215cc4Brian Paul 299e529170c11d3cb5812aabeff0a6ee2d7a2ea66f2Keith Whitwell#endif 300