Path: blob/21.2-virgl/src/gallium/drivers/r300/r300_cs.h
4570 views
/*1* Copyright 2008 Corbin Simpson <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE. */2122/**23* This file contains macros for immediate command submission.24*/2526#ifndef R300_CS_H27#define R300_CS_H2829#include "r300_reg.h"30#include "r300_context.h"3132/* Yes, I know macros are ugly. However, they are much prettier than the code33* that they neatly hide away, and don't have the cost of function setup,so34* we're going to use them. */3536/**37* Command submission setup.38*/3940#define CS_LOCALS(context) \41struct radeon_cmdbuf *cs_copy = &(context)->cs; \42struct radeon_winsys *cs_winsys = (context)->rws; \43int cs_count = 0; (void) cs_count; (void) cs_winsys;4445#ifdef DEBUG4647#define BEGIN_CS(size) do { \48assert(size <= (cs_copy->current.max_dw - cs_copy->current.cdw)); \49cs_count = size; \50} while (0)5152#define END_CS do { \53if (cs_count != 0) \54debug_printf("r300: Warning: cs_count off by %d at (%s, %s:%i)\n", \55cs_count, __FUNCTION__, __FILE__, __LINE__); \56cs_count = 0; \57} while (0)5859#define CS_USED_DW(x) cs_count -= (x)6061#else6263#define BEGIN_CS(size)64#define END_CS65#define CS_USED_DW(x)6667#endif6869/**70* Writing pure DWORDs.71*/7273#define OUT_CS(value) do { \74cs_copy->current.buf[cs_copy->current.cdw++] = (value); \75CS_USED_DW(1); \76} while (0)7778#define OUT_CS_32F(value) \79OUT_CS(fui(value))8081#define OUT_CS_REG(register, value) do { \82OUT_CS(CP_PACKET0(register, 0)); \83OUT_CS(value); \84} while (0)8586/* Note: This expects count to be the number of registers,87* not the actual packet0 count! */88#define OUT_CS_REG_SEQ(register, count) \89OUT_CS(CP_PACKET0((register), ((count) - 1)))9091#define OUT_CS_ONE_REG(register, count) \92OUT_CS(CP_PACKET0((register), ((count) - 1)) | RADEON_ONE_REG_WR)9394#define OUT_CS_PKT3(op, count) \95OUT_CS(CP_PACKET3(op, count))9697#define OUT_CS_TABLE(values, count) do { \98memcpy(cs_copy->current.buf + cs_copy->current.cdw, (values), (count) * 4); \99cs_copy->current.cdw += (count); \100CS_USED_DW(count); \101} while (0)102103104/**105* Writing buffers.106*/107108#define OUT_CS_RELOC(r) do { \109assert((r)); \110assert((r)->buf); \111OUT_CS(0xc0001000); /* PKT3_NOP */ \112OUT_CS(cs_winsys->cs_lookup_buffer(cs_copy, (r)->buf) * 4); \113} while (0)114115116/**117* Command buffer emission.118*/119120#define WRITE_CS_TABLE(values, count) do { \121assert(cs_count == 0); \122memcpy(cs_copy->current.buf + cs_copy->current.cdw, (values), (count) * 4); \123cs_copy->current.cdw += (count); \124} while (0)125126#endif /* R300_CS_H */127128129