1af69d88dSmrg/* 2af69d88dSmrg * Copyright 2012 Advanced Micro Devices, Inc. 301e04c3fSmrg * All Rights Reserved. 4af69d88dSmrg * 5af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a 6af69d88dSmrg * copy of this software and associated documentation files (the "Software"), 7af69d88dSmrg * to deal in the Software without restriction, including without limitation 8af69d88dSmrg * on the rights to use, copy, modify, merge, publish, distribute, sub 9af69d88dSmrg * license, and/or sell copies of the Software, and to permit persons to whom 10af69d88dSmrg * the Software is furnished to do so, subject to the following conditions: 11af69d88dSmrg * 12af69d88dSmrg * The above copyright notice and this permission notice (including the next 13af69d88dSmrg * paragraph) shall be included in all copies or substantial portions of the 14af69d88dSmrg * Software. 15af69d88dSmrg * 16af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 20af69d88dSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21af69d88dSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22af69d88dSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 23af69d88dSmrg */ 24af69d88dSmrg 25af69d88dSmrg#ifndef SI_PM4_H 26af69d88dSmrg#define SI_PM4_H 27af69d88dSmrg 2801e04c3fSmrg#include "radeon/radeon_winsys.h" 29af69d88dSmrg 307ec681f3Smrg#ifdef __cplusplus 317ec681f3Smrgextern "C" { 327ec681f3Smrg#endif 337ec681f3Smrg 347ec681f3Smrg#define SI_PM4_MAX_DW 176 35af69d88dSmrg 36af69d88dSmrg// forward defines 37af69d88dSmrgstruct si_context; 3801e04c3fSmrg 3901e04c3fSmrg/* State atoms are callbacks which write a sequence of packets into a GPU 4001e04c3fSmrg * command buffer (AKA indirect buffer, AKA IB, AKA command stream, AKA CS). 4101e04c3fSmrg */ 4201e04c3fSmrgstruct si_atom { 437ec681f3Smrg void (*emit)(struct si_context *ctx); 4401e04c3fSmrg}; 45af69d88dSmrg 467ec681f3Smrgstruct si_pm4_state { 477ec681f3Smrg /* PKT3_SET_*_REG handling */ 487ec681f3Smrg unsigned last_opcode; 497ec681f3Smrg unsigned last_reg; 507ec681f3Smrg unsigned last_pm4; 51af69d88dSmrg 527ec681f3Smrg /* commands for the DE */ 537ec681f3Smrg unsigned ndw; 547ec681f3Smrg uint32_t pm4[SI_PM4_MAX_DW]; 55af69d88dSmrg 567ec681f3Smrg /* For shader states only */ 577ec681f3Smrg bool is_shader; 587ec681f3Smrg struct si_atom atom; 59af69d88dSmrg}; 60af69d88dSmrg 61af69d88dSmrgvoid si_pm4_cmd_add(struct si_pm4_state *state, uint32_t dw); 62af69d88dSmrgvoid si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val); 63af69d88dSmrg 6401e04c3fSmrgvoid si_pm4_clear_state(struct si_pm4_state *state); 657ec681f3Smrgvoid si_pm4_free_state(struct si_context *sctx, struct si_pm4_state *state, unsigned idx); 66af69d88dSmrg 67af69d88dSmrgvoid si_pm4_emit(struct si_context *sctx, struct si_pm4_state *state); 687ec681f3Smrgvoid si_pm4_reset_emitted(struct si_context *sctx, bool first_cs); 697ec681f3Smrg 707ec681f3Smrg#ifdef __cplusplus 717ec681f3Smrg} 727ec681f3Smrg#endif 73af69d88dSmrg 74af69d88dSmrg#endif 75