Initial R6xx/R7xx EXA and textured video support

This commit is contained in:
Alex Deucher 2009-02-03 10:44:10 -05:00
commit d1f071c7f1
20 changed files with 10093 additions and 185 deletions

View file

@ -66,7 +66,7 @@ XMODE_SRCS=\
modes/xf86DiDGA.c
if USE_EXA
RADEON_EXA_SOURCES = radeon_exa.c
RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c
endif
AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ @XMODES_CFLAGS@ -DDISABLE_EASF -DENABLE_ALL_SERVICE_FUNCTIONS -DATOM_BIOS -DATOM_BIOS_PARSER -DDRIVER_PARSER
@ -128,6 +128,12 @@ EXTRA_DIST = \
radeon_render.c \
radeon_accelfuncs.c \
radeon_textured_videofuncs.c \
r600_reg.h \
r600_reg_auto_r6xx.h \
r600_reg_r6xx.h \
r600_reg_r7xx.h \
r600_shader.h \
r600_state.h \
ati.h \
ativersion.h \
bicubic_table.h \

3663
src/r600_exa.c Normal file

File diff suppressed because it is too large Load diff

118
src/r600_reg.h Normal file
View file

@ -0,0 +1,118 @@
/*
* RadeonHD R6xx, R7xx Register documentation
*
* Copyright (C) 2008-2009 Advanced Micro Devices, Inc.
* Copyright (C) 2008-2009 Matthias Hopf
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _R600_REG_H_
#define _R600_REG_H_
/*
* Register definitions
*/
#include "r600_reg_auto_r6xx.h"
#include "r600_reg_r6xx.h"
#include "r600_reg_r7xx.h"
/* SET_*_REG offsets + ends */
enum {
SET_CONFIG_REG_offset = 0x00008000,
SET_CONFIG_REG_end = 0x0000ac00,
SET_CONTEXT_REG_offset = 0x00028000,
SET_CONTEXT_REG_end = 0x00029000,
SET_ALU_CONST_offset = 0x00030000,
SET_ALU_CONST_end = 0x00032000,
SET_RESOURCE_offset = 0x00038000,
SET_RESOURCE_end = 0x0003c000,
SET_SAMPLER_offset = 0x0003c000,
SET_SAMPLER_end = 0x0003cff0,
SET_CTL_CONST_offset = 0x0003cff0,
SET_CTL_CONST_end = 0x0003e200,
SET_LOOP_CONST_offset = 0x0003e200,
SET_LOOP_CONST_end = 0x0003e380,
SET_BOOL_CONST_offset = 0x0003e380,
SET_BOOL_CONST_end = 0x00040000,
} ;
/* packet3 IT_SURFACE_BASE_UPDATE bits */
enum {
DEPTH_BASE = (1 << 0),
COLOR0_BASE = (1 << 1),
COLOR1_BASE = (1 << 2),
COLOR2_BASE = (1 << 3),
COLOR3_BASE = (1 << 4),
COLOR4_BASE = (1 << 5),
COLOR5_BASE = (1 << 6),
COLOR6_BASE = (1 << 7),
COLOR7_BASE = (1 << 8),
STRMOUT_BASE0 = (1 << 9),
STRMOUT_BASE1 = (1 << 10),
STRMOUT_BASE2 = (1 << 11),
STRMOUT_BASE3 = (1 << 12),
COHER_BASE0 = (1 << 13),
COHER_BASE1 = (1 << 14),
};
/* Packet3 commands */
enum {
IT_NOP = 0x10,
IT_INDIRECT_BUFFER_END = 0x17,
IT_SET_PREDICATION = 0x20,
IT_REG_RMW = 0x21,
IT_COND_EXEC = 0x22,
IT_PRED_EXEC = 0x23,
IT_START_3D_CMDBUF = 0x24,
IT_DRAW_INDEX_2 = 0x27,
IT_CONTEXT_CONTROL = 0x28,
IT_DRAW_INDEX_IMMD_BE = 0x29,
IT_INDEX_TYPE = 0x2A,
IT_DRAW_INDEX = 0x2B,
IT_DRAW_INDEX_AUTO = 0x2D,
IT_DRAW_INDEX_IMMD = 0x2E,
IT_NUM_INSTANCES = 0x2F,
IT_STRMOUT_BUFFER_UPDATE = 0x34,
IT_INDIRECT_BUFFER_MP = 0x38,
IT_MEM_SEMAPHORE = 0x39,
IT_MPEG_INDEX = 0x3A,
IT_WAIT_REG_MEM = 0x3C,
IT_MEM_WRITE = 0x3D,
IT_INDIRECT_BUFFER = 0x32,
IT_CP_INTERRUPT = 0x40,
IT_SURFACE_SYNC = 0x43,
IT_ME_INITIALIZE = 0x44,
IT_COND_WRITE = 0x45,
IT_EVENT_WRITE = 0x46,
IT_EVENT_WRITE_EOP = 0x47,
IT_ONE_REG_WRITE = 0x57,
IT_SET_CONFIG_REG = 0x68,
IT_SET_CONTEXT_REG = 0x69,
IT_SET_ALU_CONST = 0x6A,
IT_SET_BOOL_CONST = 0x6B,
IT_SET_LOOP_CONST = 0x6C,
IT_SET_RESOURCE = 0x6D,
IT_SET_SAMPLER = 0x6E,
IT_SET_CTL_CONST = 0x6F,
IT_SURFACE_BASE_UPDATE = 0x73,
} ;
#endif

3087
src/r600_reg_auto_r6xx.h Normal file

File diff suppressed because it is too large Load diff

494
src/r600_reg_r6xx.h Normal file
View file

@ -0,0 +1,494 @@
/*
* RadeonHD R6xx, R7xx Register documentation
*
* Copyright (C) 2008-2009 Advanced Micro Devices, Inc.
* Copyright (C) 2008-2009 Matthias Hopf
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _R600_REG_R6xx_H_
#define _R600_REG_R6xx_H_
/*
* Registers for R6xx chips that are not documented yet
*/
enum {
MM_INDEX = 0x0000,
MM_DATA = 0x0004,
SRBM_STATUS = 0x0e50,
RLC_RQ_PENDING_bit = 1 << 3,
RCU_RQ_PENDING_bit = 1 << 4,
GRBM_RQ_PENDING_bit = 1 << 5,
HI_RQ_PENDING_bit = 1 << 6,
IO_EXTERN_SIGNAL_bit = 1 << 7,
VMC_BUSY_bit = 1 << 8,
MCB_BUSY_bit = 1 << 9,
MCDZ_BUSY_bit = 1 << 10,
MCDY_BUSY_bit = 1 << 11,
MCDX_BUSY_bit = 1 << 12,
MCDW_BUSY_bit = 1 << 13,
SEM_BUSY_bit = 1 << 14,
SRBM_STATUS__RLC_BUSY_bit = 1 << 15,
PDMA_BUSY_bit = 1 << 16,
IH_BUSY_bit = 1 << 17,
CSC_BUSY_bit = 1 << 20,
CMC7_BUSY_bit = 1 << 21,
CMC6_BUSY_bit = 1 << 22,
CMC5_BUSY_bit = 1 << 23,
CMC4_BUSY_bit = 1 << 24,
CMC3_BUSY_bit = 1 << 25,
CMC2_BUSY_bit = 1 << 26,
CMC1_BUSY_bit = 1 << 27,
CMC0_BUSY_bit = 1 << 28,
BIF_BUSY_bit = 1 << 29,
IDCT_BUSY_bit = 1 << 30,
SRBM_READ_ERROR = 0x0e98,
READ_ADDRESS_mask = 0xffff << 2,
READ_ADDRESS_shift = 2,
READ_REQUESTER_HI_bit = 1 << 24,
READ_REQUESTER_GRBM_bit = 1 << 25,
READ_REQUESTER_RCU_bit = 1 << 26,
READ_REQUESTER_RLC_bit = 1 << 27,
READ_ERROR_bit = 1 << 31,
SRBM_INT_STATUS = 0x0ea4,
RDERR_INT_STAT_bit = 1 << 0,
GFX_CNTX_SWITCH_INT_STAT_bit = 1 << 1,
SRBM_INT_ACK = 0x0ea8,
RDERR_INT_ACK_bit = 1 << 0,
GFX_CNTX_SWITCH_INT_ACK_bit = 1 << 1,
R6XX_MC_VM_FB_LOCATION = 0x2180,
VENDOR_DEVICE_ID = 0x4000,
HDP_MEM_COHERENCY_FLUSH_CNTL = 0x5480,
D1GRPH_PRIMARY_SURFACE_ADDRESS = 0x6110,
D1GRPH_PITCH = 0x6120,
D1GRPH_Y_END = 0x6138,
GRBM_STATUS = 0x8010,
CMDFIFO_AVAIL_mask = 0x1f << 0,
CMDFIFO_AVAIL_shift = 0,
SRBM_RQ_PENDING_bit = 1 << 5,
CP_RQ_PENDING_bit = 1 << 6,
CF_RQ_PENDING_bit = 1 << 7,
PF_RQ_PENDING_bit = 1 << 8,
GRBM_EE_BUSY_bit = 1 << 10,
GRBM_STATUS__VC_BUSY_bit = 1 << 11,
DB03_CLEAN_bit = 1 << 12,
CB03_CLEAN_bit = 1 << 13,
VGT_BUSY_NO_DMA_bit = 1 << 16,
GRBM_STATUS__VGT_BUSY_bit = 1 << 17,
TA03_BUSY_bit = 1 << 18,
GRBM_STATUS__TC_BUSY_bit = 1 << 19,
SX_BUSY_bit = 1 << 20,
SH_BUSY_bit = 1 << 21,
SPI03_BUSY_bit = 1 << 22,
SMX_BUSY_bit = 1 << 23,
SC_BUSY_bit = 1 << 24,
PA_BUSY_bit = 1 << 25,
DB03_BUSY_bit = 1 << 26,
CR_BUSY_bit = 1 << 27,
CP_COHERENCY_BUSY_bit = 1 << 28,
GRBM_STATUS__CP_BUSY_bit = 1 << 29,
CB03_BUSY_bit = 1 << 30,
GUI_ACTIVE_bit = 1 << 31,
GRBM_STATUS2 = 0x8014,
CR_CLEAN_bit = 1 << 0,
SMX_CLEAN_bit = 1 << 1,
SPI0_BUSY_bit = 1 << 8,
SPI1_BUSY_bit = 1 << 9,
SPI2_BUSY_bit = 1 << 10,
SPI3_BUSY_bit = 1 << 11,
TA0_BUSY_bit = 1 << 12,
TA1_BUSY_bit = 1 << 13,
TA2_BUSY_bit = 1 << 14,
TA3_BUSY_bit = 1 << 15,
DB0_BUSY_bit = 1 << 16,
DB1_BUSY_bit = 1 << 17,
DB2_BUSY_bit = 1 << 18,
DB3_BUSY_bit = 1 << 19,
CB0_BUSY_bit = 1 << 20,
CB1_BUSY_bit = 1 << 21,
CB2_BUSY_bit = 1 << 22,
CB3_BUSY_bit = 1 << 23,
GRBM_SOFT_RESET = 0x8020,
SOFT_RESET_CP_bit = 1 << 0,
SOFT_RESET_CB_bit = 1 << 1,
SOFT_RESET_CR_bit = 1 << 2,
SOFT_RESET_DB_bit = 1 << 3,
SOFT_RESET_PA_bit = 1 << 5,
SOFT_RESET_SC_bit = 1 << 6,
SOFT_RESET_SMX_bit = 1 << 7,
SOFT_RESET_SPI_bit = 1 << 8,
SOFT_RESET_SH_bit = 1 << 9,
SOFT_RESET_SX_bit = 1 << 10,
SOFT_RESET_TC_bit = 1 << 11,
SOFT_RESET_TA_bit = 1 << 12,
SOFT_RESET_VC_bit = 1 << 13,
SOFT_RESET_VGT_bit = 1 << 14,
SOFT_RESET_GRBM_GCA_bit = 1 << 15,
WAIT_UNTIL = 0x8040,
WAIT_CP_DMA_IDLE_bit = 1 << 8,
WAIT_CMDFIFO_bit = 1 << 10,
WAIT_2D_IDLE_bit = 1 << 14,
WAIT_3D_IDLE_bit = 1 << 15,
WAIT_2D_IDLECLEAN_bit = 1 << 16,
WAIT_3D_IDLECLEAN_bit = 1 << 17,
WAIT_EXTERN_SIG_bit = 1 << 19,
CMDFIFO_ENTRIES_mask = 0x1f << 20,
CMDFIFO_ENTRIES_shift = 20,
GRBM_READ_ERROR = 0x8058,
/* READ_ADDRESS_mask = 0xffff << 2, */
/* READ_ADDRESS_shift = 2, */
READ_REQUESTER_SRBM_bit = 1 << 28,
READ_REQUESTER_CP_bit = 1 << 29,
READ_REQUESTER_WU_POLL_bit = 1 << 30,
/* READ_ERROR_bit = 1 << 31, */
SCRATCH_REG0 = 0x8500,
SCRATCH_REG1 = 0x8504,
SCRATCH_REG2 = 0x8508,
SCRATCH_REG3 = 0x850c,
SCRATCH_REG4 = 0x8510,
SCRATCH_REG5 = 0x8514,
SCRATCH_REG6 = 0x8518,
SCRATCH_REG7 = 0x851c,
SCRATCH_UMSK = 0x8540,
SCRATCH_ADDR = 0x8544,
CP_COHER_CNTL = 0x85f0,
DEST_BASE_0_ENA_bit = 1 << 0,
DEST_BASE_1_ENA_bit = 1 << 1,
SO0_DEST_BASE_ENA_bit = 1 << 2,
SO1_DEST_BASE_ENA_bit = 1 << 3,
SO2_DEST_BASE_ENA_bit = 1 << 4,
SO3_DEST_BASE_ENA_bit = 1 << 5,
CB0_DEST_BASE_ENA_bit = 1 << 6,
CB1_DEST_BASE_ENA_bit = 1 << 7,
CB2_DEST_BASE_ENA_bit = 1 << 8,
CB3_DEST_BASE_ENA_bit = 1 << 9,
CB4_DEST_BASE_ENA_bit = 1 << 10,
CB5_DEST_BASE_ENA_bit = 1 << 11,
CB6_DEST_BASE_ENA_bit = 1 << 12,
CB7_DEST_BASE_ENA_bit = 1 << 13,
DB_DEST_BASE_ENA_bit = 1 << 14,
CR_DEST_BASE_ENA_bit = 1 << 15,
TC_ACTION_ENA_bit = 1 << 23,
VC_ACTION_ENA_bit = 1 << 24,
CB_ACTION_ENA_bit = 1 << 25,
DB_ACTION_ENA_bit = 1 << 26,
SH_ACTION_ENA_bit = 1 << 27,
SMX_ACTION_ENA_bit = 1 << 28,
CR0_ACTION_ENA_bit = 1 << 29,
CR1_ACTION_ENA_bit = 1 << 30,
CR2_ACTION_ENA_bit = 1 << 31,
CP_COHER_SIZE = 0x85f4,
CP_COHER_BASE = 0x85f8,
CP_COHER_STATUS = 0x85fc,
MATCHING_GFX_CNTX_mask = 0xff << 0,
MATCHING_GFX_CNTX_shift = 0,
MATCHING_CR_CNTX_mask = 0xffff << 8,
MATCHING_CR_CNTX_shift = 8,
STATUS_bit = 1 << 31,
CP_STALLED_STAT1 = 0x8674,
RBIU_TO_DMA_NOT_RDY_TO_RCV_bit = 1 << 0,
RBIU_TO_IBS_NOT_RDY_TO_RCV_bit = 1 << 1,
RBIU_TO_SEM_NOT_RDY_TO_RCV_bit = 1 << 2,
RBIU_TO_2DREGS_NOT_RDY_TO_RCV_bit = 1 << 3,
RBIU_TO_MEMWR_NOT_RDY_TO_RCV_bit = 1 << 4,
RBIU_TO_MEMRD_NOT_RDY_TO_RCV_bit = 1 << 5,
RBIU_TO_EOPD_NOT_RDY_TO_RCV_bit = 1 << 6,
RBIU_TO_RECT_NOT_RDY_TO_RCV_bit = 1 << 7,
RBIU_TO_STRMO_NOT_RDY_TO_RCV_bit = 1 << 8,
RBIU_TO_PSTAT_NOT_RDY_TO_RCV_bit = 1 << 9,
MIU_WAITING_ON_RDREQ_FREE_bit = 1 << 16,
MIU_WAITING_ON_WRREQ_FREE_bit = 1 << 17,
MIU_NEEDS_AVAIL_WRREQ_PHASE_bit = 1 << 18,
RCIU_WAITING_ON_GRBM_FREE_bit = 1 << 24,
RCIU_WAITING_ON_VGT_FREE_bit = 1 << 25,
RCIU_STALLED_ON_ME_READ_bit = 1 << 26,
RCIU_STALLED_ON_DMA_READ_bit = 1 << 27,
RCIU_HALTED_BY_REG_VIOLATION_bit = 1 << 28,
CP_STALLED_STAT2 = 0x8678,
PFP_TO_CSF_NOT_RDY_TO_RCV_bit = 1 << 0,
PFP_TO_MEQ_NOT_RDY_TO_RCV_bit = 1 << 1,
PFP_TO_VGT_NOT_RDY_TO_RCV_bit = 1 << 2,
PFP_HALTED_BY_INSTR_VIOLATION_bit = 1 << 3,
MULTIPASS_IB_PENDING_IN_PFP_bit = 1 << 4,
ME_BRUSH_WC_NOT_RDY_TO_RCV_bit = 1 << 8,
ME_STALLED_ON_BRUSH_LOGIC_bit = 1 << 9,
CR_CNTX_NOT_AVAIL_TO_ME_bit = 1 << 10,
GFX_CNTX_NOT_AVAIL_TO_ME_bit = 1 << 11,
ME_RCIU_NOT_RDY_TO_RCV_bit = 1 << 12,
ME_TO_CONST_NOT_RDY_TO_RCV_bit = 1 << 13,
ME_WAITING_DATA_FROM_PFP_bit = 1 << 14,
ME_WAITING_ON_PARTIAL_FLUSH_bit = 1 << 15,
RECT_FIFO_NEEDS_CR_RECT_DONE_bit = 1 << 16,
RECT_FIFO_NEEDS_WR_CONFIRM_bit = 1 << 17,
EOPD_FIFO_NEEDS_SC_EOP_DONE_bit = 1 << 18,
EOPD_FIFO_NEEDS_SMX_EOP_DONE_bit = 1 << 19,
EOPD_FIFO_NEEDS_WR_CONFIRM_bit = 1 << 20,
EOPD_FIFO_NEEDS_SIGNAL_SEM_bit = 1 << 21,
SO_NUMPRIM_FIFO_NEEDS_SOADDR_bit = 1 << 22,
SO_NUMPRIM_FIFO_NEEDS_NUMPRIM_bit = 1 << 23,
PIPE_STATS_FIFO_NEEDS_SAMPLE_bit = 1 << 24,
SURF_SYNC_NEEDS_IDLE_CNTXS_bit = 1 << 30,
SURF_SYNC_NEEDS_ALL_CLEAN_bit = 1 << 31,
CP_BUSY_STAT = 0x867c,
REG_BUS_FIFO_BUSY_bit = 1 << 0,
RING_FETCHING_DATA_bit = 1 << 1,
INDR1_FETCHING_DATA_bit = 1 << 2,
INDR2_FETCHING_DATA_bit = 1 << 3,
STATE_FETCHING_DATA_bit = 1 << 4,
PRED_FETCHING_DATA_bit = 1 << 5,
COHER_CNTR_NEQ_ZERO_bit = 1 << 6,
PFP_PARSING_PACKETS_bit = 1 << 7,
ME_PARSING_PACKETS_bit = 1 << 8,
RCIU_PFP_BUSY_bit = 1 << 9,
RCIU_ME_BUSY_bit = 1 << 10,
OUTSTANDING_READ_TAGS_bit = 1 << 11,
SEM_CMDFIFO_NOT_EMPTY_bit = 1 << 12,
SEM_FAILED_AND_HOLDING_bit = 1 << 13,
SEM_POLLING_FOR_PASS_bit = 1 << 14,
_3D_BUSY_bit = 1 << 15,
_2D_BUSY_bit = 1 << 16,
CP_STAT = 0x8680,
CSF_RING_BUSY_bit = 1 << 0,
CSF_WPTR_POLL_BUSY_bit = 1 << 1,
CSF_INDIRECT1_BUSY_bit = 1 << 2,
CSF_INDIRECT2_BUSY_bit = 1 << 3,
CSF_STATE_BUSY_bit = 1 << 4,
CSF_PREDICATE_BUSY_bit = 1 << 5,
CSF_BUSY_bit = 1 << 6,
MIU_RDREQ_BUSY_bit = 1 << 7,
MIU_WRREQ_BUSY_bit = 1 << 8,
ROQ_RING_BUSY_bit = 1 << 9,
ROQ_INDIRECT1_BUSY_bit = 1 << 10,
ROQ_INDIRECT2_BUSY_bit = 1 << 11,
ROQ_STATE_BUSY_bit = 1 << 12,
ROQ_PREDICATE_BUSY_bit = 1 << 13,
ROQ_ALIGN_BUSY_bit = 1 << 14,
PFP_BUSY_bit = 1 << 15,
MEQ_BUSY_bit = 1 << 16,
ME_BUSY_bit = 1 << 17,
QUERY_BUSY_bit = 1 << 18,
SEMAPHORE_BUSY_bit = 1 << 19,
INTERRUPT_BUSY_bit = 1 << 20,
SURFACE_SYNC_BUSY_bit = 1 << 21,
DMA_BUSY_bit = 1 << 22,
RCIU_BUSY_bit = 1 << 23,
CP_STAT__CP_BUSY_bit = 1 << 31,
CP_ME_CNTL = 0x86d8,
ME_STATMUX_mask = 0xff << 0,
ME_STATMUX_shift = 0,
ME_HALT_bit = 1 << 28,
CP_ME_STATUS = 0x86dc,
CP_RB_RPTR = 0x8700,
RB_RPTR_mask = 0xfffff << 0,
RB_RPTR_shift = 0,
CP_RB_WPTR_DELAY = 0x8704,
PRE_WRITE_TIMER_mask = 0xfffffff << 0,
PRE_WRITE_TIMER_shift = 0,
PRE_WRITE_LIMIT_mask = 0x0f << 28,
PRE_WRITE_LIMIT_shift = 28,
CP_ROQ_RB_STAT = 0x8780,
ROQ_RPTR_PRIMARY_mask = 0x3ff << 0,
ROQ_RPTR_PRIMARY_shift = 0,
ROQ_WPTR_PRIMARY_mask = 0x3ff << 16,
ROQ_WPTR_PRIMARY_shift = 16,
CP_ROQ_IB1_STAT = 0x8784,
ROQ_RPTR_INDIRECT1_mask = 0x3ff << 0,
ROQ_RPTR_INDIRECT1_shift = 0,
ROQ_WPTR_INDIRECT1_mask = 0x3ff << 16,
ROQ_WPTR_INDIRECT1_shift = 16,
CP_ROQ_IB2_STAT = 0x8788,
ROQ_RPTR_INDIRECT2_mask = 0x3ff << 0,
ROQ_RPTR_INDIRECT2_shift = 0,
ROQ_WPTR_INDIRECT2_mask = 0x3ff << 16,
ROQ_WPTR_INDIRECT2_shift = 16,
CP_MEQ_STAT = 0x8794,
MEQ_RPTR_mask = 0x3ff << 0,
MEQ_RPTR_shift = 0,
MEQ_WPTR_mask = 0x3ff << 16,
MEQ_WPTR_shift = 16,
CC_GC_SHADER_PIPE_CONFIG = 0x8950,
INACTIVE_QD_PIPES_mask = 0xff << 8,
INACTIVE_QD_PIPES_shift = 8,
R6XX_MAX_QD_PIPES = 8,
INACTIVE_SIMDS_mask = 0xff << 16,
INACTIVE_SIMDS_shift = 16,
R6XX_MAX_SIMDS = 8,
GC_USER_SHADER_PIPE_CONFIG = 0x8954,
VC_ENHANCE = 0x9714,
DB_DEBUG = 0x9830,
PREZ_MUST_WAIT_FOR_POSTZ_DONE = 1 << 31,
DB_WATERMARKS = 0x00009838,
DEPTH_FREE_mask = 0x1f << 0,
DEPTH_FREE_shift = 0,
DEPTH_FLUSH_mask = 0x3f << 5,
DEPTH_FLUSH_shift = 5,
FORCE_SUMMARIZE_mask = 0x0f << 11,
FORCE_SUMMARIZE_shift = 11,
DEPTH_PENDING_FREE_mask = 0x1f << 15,
DEPTH_PENDING_FREE_shift = 15,
DEPTH_CACHELINE_FREE_mask = 0x1f << 20,
DEPTH_CACHELINE_FREE_shift = 20,
EARLY_Z_PANIC_DISABLE_bit = 1 << 25,
LATE_Z_PANIC_DISABLE_bit = 1 << 26,
RE_Z_PANIC_DISABLE_bit = 1 << 27,
DB_EXTRA_DEBUG_mask = 0x0f << 28,
DB_EXTRA_DEBUG_shift = 28,
CP_RB_BASE = 0xc100,
CP_RB_CNTL = 0xc104,
RB_BUFSZ_mask = 0x3f << 0,
CP_RB_WPTR = 0xc114,
RB_WPTR_mask = 0xfffff << 0,
RB_WPTR_shift = 0,
CP_RB_RPTR_WR = 0xc108,
RB_RPTR_WR_mask = 0xfffff << 0,
RB_RPTR_WR_shift = 0,
CP_INT_STATUS = 0xc128,
DISABLE_CNTX_SWITCH_INT_STAT_bit = 1 << 0,
ENABLE_CNTX_SWITCH_INT_STAT_bit = 1 << 1,
SEM_SIGNAL_INT_STAT_bit = 1 << 18,
CNTX_BUSY_INT_STAT_bit = 1 << 19,
CNTX_EMPTY_INT_STAT_bit = 1 << 20,
WAITMEM_SEM_INT_STAT_bit = 1 << 21,
PRIV_INSTR_INT_STAT_bit = 1 << 22,
PRIV_REG_INT_STAT_bit = 1 << 23,
OPCODE_ERROR_INT_STAT_bit = 1 << 24,
SCRATCH_INT_STAT_bit = 1 << 25,
TIME_STAMP_INT_STAT_bit = 1 << 26,
RESERVED_BIT_ERROR_INT_STAT_bit = 1 << 27,
DMA_INT_STAT_bit = 1 << 28,
IB2_INT_STAT_bit = 1 << 29,
IB1_INT_STAT_bit = 1 << 30,
RB_INT_STAT_bit = 1 << 31,
// SX_ALPHA_TEST_CONTROL = 0x00028410,
ALPHA_FUNC__REF_NEVER = 0,
ALPHA_FUNC__REF_ALWAYS = 7,
// DB_SHADER_CONTROL = 0x0002880c,
Z_ORDER__EARLY_Z_THEN_LATE_Z = 2,
// PA_SU_SC_MODE_CNTL = 0x00028814,
// POLY_MODE_mask = 0x03 << 3,
POLY_MODE__TRIANGLES = 0, POLY_MODE__DUAL_MODE,
// POLYMODE_FRONT_PTYPE_mask = 0x07 << 5,
POLYMODE_PTYPE__POINTS = 0, POLYMODE_PTYPE__LINES, POLYMODE_PTYPE__TRIANGLES,
PA_SC_AA_SAMPLE_LOCS_8S_WD1_M = 0x00028c20,
DB_SRESULTS_COMPARE_STATE0 = 0x00028d28, /* See autoregs: DB_SRESULTS_COMPARE_STATE1 */
// DB_SRESULTS_COMPARE_STATE1 = 0x00028d2c,
DB_ALPHA_TO_MASK = 0x00028d44,
ALPHA_TO_MASK_ENABLE = 1 << 0,
ALPHA_TO_MASK_OFFSET0_mask = 0x03 << 8,
ALPHA_TO_MASK_OFFSET0_shift = 8,
ALPHA_TO_MASK_OFFSET1_mask = 0x03 << 8,
ALPHA_TO_MASK_OFFSET1_shift = 10,
ALPHA_TO_MASK_OFFSET2_mask = 0x03 << 8,
ALPHA_TO_MASK_OFFSET2_shift = 12,
ALPHA_TO_MASK_OFFSET3_mask = 0x03 << 8,
ALPHA_TO_MASK_OFFSET3_shift = 14,
// SQ_VTX_CONSTANT_WORD2_0 = 0x00038008,
// SQ_VTX_CONSTANT_WORD2_0__DATA_FORMAT_mask = 0x3f << 20,
FMT_INVALID=0, FMT_8, FMT_4_4, FMT_3_3_2,
FMT_16=5, FMT_16_FLOAT, FMT_8_8,
FMT_5_6_5, FMT_6_5_5, FMT_1_5_5_5, FMT_4_4_4_4,
FMT_5_5_5_1, FMT_32, FMT_32_FLOAT, FMT_16_16,
FMT_16_16_FLOAT=16, FMT_8_24, FMT_8_24_FLOAT, FMT_24_8,
FMT_24_8_FLOAT, FMT_10_11_11, FMT_10_11_11_FLOAT, FMT_11_11_10,
FMT_11_11_10_FLOAT, FMT_2_10_10_10, FMT_8_8_8_8, FMT_10_10_10_2,
FMT_X24_8_32_FLOAT, FMT_32_32, FMT_32_32_FLOAT, FMT_16_16_16_16,
FMT_16_16_16_16_FLOAT=32, FMT_32_32_32_32=34, FMT_32_32_32_32_FLOAT,
FMT_1 = 37, FMT_GB_GR=39,
FMT_BG_RG, FMT_32_AS_8, FMT_32_AS_8_8, FMT_5_9_9_9_SHAREDEXP,
FMT_8_8_8, FMT_16_16_16, FMT_16_16_16_FLOAT, FMT_32_32_32,
FMT_32_32_32_FLOAT=48,
// High level register file lengths
SQ_ALU_CONSTANT = SQ_ALU_CONSTANT0_0, /* 256 PS, 256 VS */
SQ_ALU_CONSTANT_ps_num = 256,
SQ_ALU_CONSTANT_vs_num = 256,
SQ_ALU_CONSTANT_all_num = 512,
SQ_ALU_CONSTANT_offset = 16,
SQ_ALU_CONSTANT_ps = 0,
SQ_ALU_CONSTANT_vs = SQ_ALU_CONSTANT_ps + SQ_ALU_CONSTANT_ps_num,
SQ_TEX_RESOURCE = SQ_TEX_RESOURCE_WORD0_0, /* 160 PS, 160 VS, 16 FS, 160 GS */
SQ_TEX_RESOURCE_ps_num = 160,
SQ_TEX_RESOURCE_vs_num = 160,
SQ_TEX_RESOURCE_fs_num = 16,
SQ_TEX_RESOURCE_gs_num = 160,
SQ_TEX_RESOURCE_all_num = 496,
SQ_TEX_RESOURCE_offset = 28,
SQ_TEX_RESOURCE_ps = 0,
SQ_TEX_RESOURCE_vs = SQ_TEX_RESOURCE_ps + SQ_TEX_RESOURCE_ps_num,
SQ_TEX_RESOURCE_fs = SQ_TEX_RESOURCE_vs + SQ_TEX_RESOURCE_vs_num,
SQ_TEX_RESOURCE_gs = SQ_TEX_RESOURCE_fs + SQ_TEX_RESOURCE_fs_num,
SQ_VTX_RESOURCE = SQ_VTX_CONSTANT_WORD0_0, /* 160 PS, 160 VS, 16 FS, 160 GS */
SQ_VTX_RESOURCE_ps_num = 160,
SQ_VTX_RESOURCE_vs_num = 160,
SQ_VTX_RESOURCE_fs_num = 16,
SQ_VTX_RESOURCE_gs_num = 160,
SQ_VTX_RESOURCE_all_num = 496,
SQ_VTX_RESOURCE_offset = 28,
SQ_VTX_RESOURCE_ps = 0,
SQ_VTX_RESOURCE_vs = SQ_VTX_RESOURCE_ps + SQ_VTX_RESOURCE_ps_num,
SQ_VTX_RESOURCE_fs = SQ_VTX_RESOURCE_vs + SQ_VTX_RESOURCE_vs_num,
SQ_VTX_RESOURCE_gs = SQ_VTX_RESOURCE_fs + SQ_VTX_RESOURCE_fs_num,
SQ_TEX_SAMPLER_WORD = SQ_TEX_SAMPLER_WORD0_0, /* 18 per PS, VS, GS */
SQ_TEX_SAMPLER_WORD_ps_num = 18,
SQ_TEX_SAMPLER_WORD_vs_num = 18,
SQ_TEX_SAMPLER_WORD_gs_num = 18,
SQ_TEX_SAMPLER_WORD_all_num = 54,
SQ_TEX_SAMPLER_WORD_offset = 12,
SQ_TEX_SAMPLER_WORD_ps = 0,
SQ_TEX_SAMPLER_WORD_vs = SQ_TEX_SAMPLER_WORD_ps + SQ_TEX_SAMPLER_WORD_ps_num,
SQ_TEX_SAMPLER_WORD_gs = SQ_TEX_SAMPLER_WORD_vs + SQ_TEX_SAMPLER_WORD_vs_num,
SQ_LOOP_CONST = SQ_LOOP_CONST_0, /* 32 per PS, VS, GS */
SQ_LOOP_CONST_ps_num = 32,
SQ_LOOP_CONST_vs_num = 32,
SQ_LOOP_CONST_gs_num = 32,
SQ_LOOP_CONST_all_num = 96,
SQ_LOOP_CONST_offset = 4,
SQ_LOOP_CONST_ps = 0,
SQ_LOOP_CONST_vs = SQ_LOOP_CONST_ps + SQ_LOOP_CONST_ps_num,
SQ_LOOP_CONST_gs = SQ_LOOP_CONST_vs + SQ_LOOP_CONST_vs_num,
} ;
#endif

149
src/r600_reg_r7xx.h Normal file
View file

@ -0,0 +1,149 @@
/*
* RadeonHD R6xx, R7xx Register documentation
*
* Copyright (C) 2008-2009 Advanced Micro Devices, Inc.
* Copyright (C) 2008-2009 Matthias Hopf
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _R600_REG_R7xx_H_
#define _R600_REG_R7xx_H_
/*
* Register update for R7xx chips
*/
enum {
R7XX_MC_VM_FB_LOCATION = 0x00002024,
// GRBM_STATUS = 0x00008010,
R7XX_TA_BUSY_bit = 1 << 14,
R7xx_SQ_DYN_GPR_CNTL_PS_FLUSH_REQ = 0x00008d8c,
RING0_OFFSET_mask = 0xff << 0,
RING0_OFFSET_shift = 0,
ISOLATE_ES_ENABLE_bit = 1 << 12,
ISOLATE_GS_ENABLE_bit = 1 << 13,
VS_PC_LIMIT_ENABLE_bit = 1 << 14,
// SQ_ALU_WORD0 = 0x00008dfc,
// SRC0_SEL_mask = 0x1ff << 0,
// SRC1_SEL_mask = 0x1ff << 13,
R7xx_SQ_ALU_SRC_1_DBL_L = 0xf4,
R7xx_SQ_ALU_SRC_1_DBL_M = 0xf5,
R7xx_SQ_ALU_SRC_0_5_DBL_L = 0xf6,
R7xx_SQ_ALU_SRC_0_5_DBL_M = 0xf7,
// INDEX_MODE_mask = 0x07 << 26,
R7xx_SQ_INDEX_GLOBAL = 0x05,
R7xx_SQ_INDEX_GLOBAL_AR_X = 0x06,
R6xx_SQ_ALU_WORD1_OP2 = 0x00008dfc,
R7xx_SQ_ALU_WORD1_OP2_V2 = 0x00008dfc,
R6xx_FOG_MERGE_bit = 1 << 5,
R6xx_OMOD_mask = 0x03 << 6,
R7xx_OMOD_mask = 0x03 << 5,
R6xx_OMOD_shift = 6,
R7xx_OMOD_shift = 5,
R6xx_SQ_ALU_WORD1_OP2__ALU_INST_mask = 0x3ff << 8,
R7xx_SQ_ALU_WORD1_OP2_V2__ALU_INST_mask = 0x7ff << 7,
R6xx_SQ_ALU_WORD1_OP2__ALU_INST_shift = 8,
R7xx_SQ_ALU_WORD1_OP2_V2__ALU_INST_shift = 7,
R7xx_SQ_OP2_INST_FREXP_64 = 0x07,
R7xx_SQ_OP2_INST_ADD_64 = 0x17,
R7xx_SQ_OP2_INST_MUL_64 = 0x1b,
R7xx_SQ_OP2_INST_FLT64_TO_FLT32 = 0x1c,
R7xx_SQ_OP2_INST_FLT32_TO_FLT64 = 0x1d,
R7xx_SQ_OP2_INST_LDEXP_64 = 0x7a,
R7xx_SQ_OP2_INST_FRACT_64 = 0x7b,
R7xx_SQ_OP2_INST_PRED_SETGT_64 = 0x7c,
R7xx_SQ_OP2_INST_PRED_SETE_64 = 0x7d,
R7xx_SQ_OP2_INST_PRED_SETGE_64 = 0x7e,
// SQ_ALU_WORD1_OP3 = 0x00008dfc,
// SRC2_SEL_mask = 0x1ff << 0,
// R7xx_SQ_ALU_SRC_1_DBL_L = 0xf4,
// R7xx_SQ_ALU_SRC_1_DBL_M = 0xf5,
// R7xx_SQ_ALU_SRC_0_5_DBL_L = 0xf6,
// R7xx_SQ_ALU_SRC_0_5_DBL_M = 0xf7,
// SQ_ALU_WORD1_OP3__ALU_INST_mask = 0x1f << 13,
R7xx_SQ_OP3_INST_MULADD_64 = 0x08,
R7xx_SQ_OP3_INST_MULADD_64_M2 = 0x09,
R7xx_SQ_OP3_INST_MULADD_64_M4 = 0x0a,
R7xx_SQ_OP3_INST_MULADD_64_D2 = 0x0b,
// SQ_CF_ALU_WORD1 = 0x00008dfc,
R6xx_USES_WATERFALL_bit = 1 << 25,
R7xx_SQ_CF_ALU_WORD1__ALT_CONST_bit = 1 << 25,
// SQ_CF_ALLOC_EXPORT_WORD0 = 0x00008dfc,
// ARRAY_BASE_mask = 0x1fff << 0,
// TYPE_mask = 0x03 << 13,
// SQ_EXPORT_PARAM = 0x02,
// X_UNUSED_FOR_SX_EXPORTS = 0x03,
// ELEM_SIZE_mask = 0x03 << 30,
// SQ_CF_ALLOC_EXPORT_WORD1 = 0x00008dfc,
// SQ_CF_ALLOC_EXPORT_WORD1__CF_INST_mask = 0x7f << 23,
R7xx_SQ_CF_INST_MEM_EXPORT = 0x3a,
// SQ_CF_WORD1 = 0x00008dfc,
// SQ_CF_WORD1__COUNT_mask = 0x07 << 10,
R7xx_COUNT_3_bit = 1 << 19,
// SQ_CF_WORD1__CF_INST_mask = 0x7f << 23,
R7xx_SQ_CF_INST_END_PROGRAM = 0x19,
R7xx_SQ_CF_INST_WAIT_ACK = 0x1a,
R7xx_SQ_CF_INST_TEX_ACK = 0x1b,
R7xx_SQ_CF_INST_VTX_ACK = 0x1c,
R7xx_SQ_CF_INST_VTX_TC_ACK = 0x1d,
// SQ_VTX_WORD0 = 0x00008dfc,
// VTX_INST_mask = 0x1f << 0,
R7xx_SQ_VTX_INST_MEM = 0x02,
// SQ_VTX_WORD2 = 0x00008dfc,
R7xx_SQ_VTX_WORD2__ALT_CONST_bit = 1 << 20,
// SQ_TEX_WORD0 = 0x00008dfc,
// TEX_INST_mask = 0x1f << 0,
R7xx_X_MEMORY_READ = 0x02,
R7xx_SQ_TEX_INST_KEEP_GRADIENTS = 0x0a,
R7xx_X_FETCH4_LOAD4_INSTRUCTION_FOR_DX10_1 = 0x0f,
R7xx_SQ_TEX_WORD0__ALT_CONST_bit = 1 << 24,
R7xx_PA_SC_EDGERULE = 0x00028230,
R7xx_SPI_THREAD_GROUPING = 0x000286c8,
PS_GROUPING_mask = 0x1f << 0,
PS_GROUPING_shift = 0,
VS_GROUPING_mask = 0x1f << 8,
VS_GROUPING_shift = 8,
GS_GROUPING_mask = 0x1f << 16,
GS_GROUPING_shift = 16,
ES_GROUPING_mask = 0x1f << 24,
ES_GROUPING_shift = 24,
R7xx_CB_SHADER_CONTROL = 0x000287a0,
RT0_ENABLE_bit = 1 << 0,
RT1_ENABLE_bit = 1 << 1,
RT2_ENABLE_bit = 1 << 2,
RT3_ENABLE_bit = 1 << 3,
RT4_ENABLE_bit = 1 << 4,
RT5_ENABLE_bit = 1 << 5,
RT6_ENABLE_bit = 1 << 6,
RT7_ENABLE_bit = 1 << 7,
// DB_ALPHA_TO_MASK = 0x00028d44,
R7xx_OFFSET_ROUND_bit = 1 << 16,
// SQ_TEX_SAMPLER_MISC_0 = 0x0003d03c,
R7xx_TRUNCATE_COORD_bit = 1 << 9,
R7xx_DISABLE_CUBE_WRAP_bit = 1 << 10,
} ;
#endif /* _R600_REG_R7xx_H_ */

346
src/r600_shader.h Normal file
View file

@ -0,0 +1,346 @@
/*
* RadeonHD R6xx, R7xx DRI driver
*
* Copyright (C) 2008-2009 Alexander Deucher
* Copyright (C) 2008-2009 Matthias Hopf
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Shader macros
*/
#ifndef __SHADER_H__
#define __SHADER_H__
/* Restrictions of ALU instructions
* order of scalar ops is always x,y,z,w,t(rans), last to be indicated by last==1.
* max of 3 different src GPRs per instr.
* max of 4 different cfile constant components per instr.
* max of 2 (different) constants (any type) for t.
* bank swizzle (see below).
* GPR write stalls read of same register. Auto-replaced by PV/PS, NOP needed if registers are relative to
* different indices (gpr,loop,nothing).
* may use constant registers or constant cache, but not both.
*/
/* Bank_swizzle: (pp. 297ff)
* Only one of each x,y,z,w GPR component can be loaded per cycle (3 cycles per instr, called 0-2).
* per scalar instruction bank_swizzle can select which cycle each operand comes from. e.g.:
* SRC0 SRC1 SRC2 SWIZZLE cycle0 cycle1 cycle2
* 1.x 2.x 012 1.x 2.x -
* 3.x 1.y 201 1.y - 3.x
* 2.x 1.y 102 (1.y) (2.x) -
* If data is read in a cycle, multiple scalar instructions can reference it.
* Special case: square() - i.e. same component in src0+src1 doesn't need read port -> ignores swizzle for src1.
* No restrictions for constants or PV/PS.
* t can load multiple components in a single cycle slot, but has to share cycles with xyzw.
* t with single constant may not load GPRs or PV/PS in cycle 0 (carefull with ALU_TRANS_210).
* t with two constants may only load GPRs or PV/PS in cycle 2.
*/
/* Oder of instructions: All CF, All ALU, All Tex/Vtx fetches */
// CF insts
// addr
#define ADDR(x) (x)
// pc
#define POP_COUNT(x) (x)
// const
#define CF_CONST(x) (x)
// cond
#define COND(x) (x) // SQ_COND_*
// count
#define I_COUNT(x) ((x) ? ((x) - 1) : 0)
//r7xx
#define COUNT_3(x) (x)
// call count
#define CALL_COUNT(x) (x)
// eop
#define END_OF_PROGRAM(x) (x)
// vpm
#define VALID_PIXEL_MODE(x) (x)
// cf inst
#define CF_INST(x) (x) // SQ_CF_INST_*
// wqm
#define WHOLE_QUAD_MODE(x) (x)
// barrier
#define BARRIER(x) (x)
//kb0
#define KCACHE_BANK0(x) (x)
//kb1
#define KCACHE_BANK1(x) (x)
// km0/1
#define KCACHE_MODE0(x) (x)
#define KCACHE_MODE1(x) (x) // SQ_CF_KCACHE_*
//
#define KCACHE_ADDR0(x) (x)
#define KCACHE_ADDR1(x) (x)
// uw
#define USES_WATERFALL(x) (x)
#define ARRAY_BASE(x) (x)
// export pixel
#define CF_PIXEL_MRT0 0
#define CF_PIXEL_MRT1 1
#define CF_PIXEL_MRT2 2
#define CF_PIXEL_MRT3 3
#define CF_PIXEL_MRT4 4
#define CF_PIXEL_MRT5 5
#define CF_PIXEL_MRT6 6
#define CF_PIXEL_MRT7 7
// *_FOG: r6xx only
#define CF_PIXEL_MRT0_FOG 16
#define CF_PIXEL_MRT1_FOG 17
#define CF_PIXEL_MRT2_FOG 18
#define CF_PIXEL_MRT3_FOG 19
#define CF_PIXEL_MRT4_FOG 20
#define CF_PIXEL_MRT5_FOG 21
#define CF_PIXEL_MRT6_FOG 22
#define CF_PIXEL_MRT7_FOG 23
#define CF_PIXEL_Z 61
// export pos
#define CF_POS0 60
#define CF_POS1 61
#define CF_POS2 62
#define CF_POS3 63
// export param
// 0...31
#define TYPE(x) (x) // SQ_EXPORT_*
#if 0
// type export
#define SQ_EXPORT_PIXEL 0
#define SQ_EXPORT_POS 1
#define SQ_EXPORT_PARAM 2
// reserved 3
// type mem
#define SQ_EXPORT_WRITE 0
#define SQ_EXPORT_WRITE_IND 1
#define SQ_EXPORT_WRITE_ACK 2
#define SQ_EXPORT_WRITE_IND_ACK 3
#endif
#define RW_GPR(x) (x)
#define RW_REL(x) (x)
#define ABSOLUTE 0
#define RELATIVE 1
#define INDEX_GPR(x) (x)
#define ELEM_SIZE(x) (x ? (x - 1) : 0)
#define COMP_MASK(x) (x)
#define R6xx_ELEM_LOOP(x) (x)
#define BURST_COUNT(x) (x ? (x - 1) : 0)
// swiz
#define SRC_SEL_X(x) (x) // SQ_SEL_* each
#define SRC_SEL_Y(x) (x)
#define SRC_SEL_Z(x) (x)
#define SRC_SEL_W(x) (x)
#define CF_DWORD0(addr) (addr)
// R7xx has another entry (COUNT3), but that is only used for adding a bit to count.
// We allow one more bit for count in the argument of the macro on R7xx instead.
// R6xx: [0,7] R7xx: [1,16]
#define CF_DWORD1(pc, cf_const, cond, count, call_count, eop, vpm, cf_inst, wqm, b) \
(((pc) << 0) | ((cf_const) << 3) | ((cond) << 8) | (((count) & 7) << 10) | (((count) >> 3) << 19) | \
((call_count) << 13) | ((eop) << 21) | ((vpm) << 22) | ((cf_inst) << 23) | ((wqm) << 30) | ((b) << 31))
#define CF_ALU_DWORD0(addr, kb0, kb1, km0) (((addr) << 0) | ((kb0) << 22) | ((kb1) << 26) | ((km0) << 30))
#define CF_ALU_DWORD1(km1, kcache_addr0, kcache_addr1, count, uw, cf_inst, wqm, b) \
(((km1) << 0) | ((kcache_addr0) << 2) | ((kcache_addr1) << 10) | \
((count) << 18) | ((uw) << 25) | ((cf_inst) << 26) | ((wqm) << 30) | ((b) << 31))
#define CF_ALLOC_IMP_EXP_DWORD0(array_base, type, rw_gpr, rr, index_gpr, es) \
(((array_base) << 0) | ((type) << 13) | ((rw_gpr) << 15) | ((rr) << 22) | ((index_gpr) << 23) | \
((es) << 30))
// R7xx apparently doesn't have the ELEM_LOOP entry any more
// We still expose it, but ELEM_LOOP is explicitely R6xx now.
// TODO: is this just forgotten in the docs, or really not available any more?
#define CF_ALLOC_IMP_EXP_DWORD1_BUF(array_size, comp_mask, el, bc, eop, vpm, cf_inst, wqm, b) \
(((array_size) << 0) | ((comp_mask) << 12) | ((el) << 16) | ((bc) << 17) | \
((eop) << 21) | ((vpm) << 22) | ((cf_inst) << 23) | ((wqm) << 30) | ((b) << 31))
#define CF_ALLOC_IMP_EXP_DWORD1_SWIZ(sel_x, sel_y, sel_z, sel_w, el, bc, eop, vpm, cf_inst, wqm, b) \
(((sel_x) << 0) | ((sel_y) << 3) | ((sel_z) << 6) | ((sel_w) << 9) | ((el) << 16) | \
((bc) << 17) | ((eop) << 21) | ((vpm) << 22) | ((cf_inst) << 23) | \
((wqm) << 30) | ((b) << 31))
// ALU clause insts
#define SRC0_SEL(x) (x)
#define SRC1_SEL(x) (x)
#define SRC2_SEL(x) (x)
// src[0-2]_sel
// 0-127 GPR
// 128-159 kcache constants bank 0
// 160-191 kcache constants bank 1
// 248-255 special SQ_ALU_SRC_* (0, 1, etc.)
#define SRC0_REL(x) (x)
#define SRC1_REL(x) (x)
#define SRC2_REL(x) (x)
// elem
#define SRC0_ELEM(x) (x)
#define SRC1_ELEM(x) (x)
#define SRC2_ELEM(x) (x)
#define ELEM_X 0
#define ELEM_Y 1
#define ELEM_Z 2
#define ELEM_W 3
// neg
#define SRC0_NEG(x) (x)
#define SRC1_NEG(x) (x)
#define SRC2_NEG(x) (x)
// im
#define INDEX_MODE(x) (x) // SQ_INDEX_*
// ps
#define PRED_SEL(x) (x) // SQ_PRED_SEL_*
// last
#define LAST(x) (x)
// abs
#define SRC0_ABS(x) (x)
#define SRC1_ABS(x) (x)
// uem
#define UPDATE_EXECUTE_MASK(x) (x)
// up
#define UPDATE_PRED(x) (x)
// wm
#define WRITE_MASK(x) (x)
// fm
#define FOG_MERGE(x) (x)
// omod
#define OMOD(x) (x) // SQ_ALU_OMOD_*
// alu inst
#define ALU_INST(x) (x) // SQ_ALU_INST_*
//bs
#define BANK_SWIZZLE(x) (x) // SQ_ALU_VEC_*
#define DST_GPR(x) (x)
#define DST_REL(x) (x)
#define DST_ELEM(x) (x)
#define CLAMP(x) (x)
#define ALU_DWORD0(src0_sel, s0r, s0e, s0n, src1_sel, s1r, s1e, s1n, im, ps, last) \
(((src0_sel) << 0) | ((s0r) << 9) | ((s0e) << 10) | ((s0n) << 12) | \
((src1_sel) << 13) | ((s1r) << 22) | ((s1e) << 23) | ((s1n) << 25) | \
((im) << 26) | ((ps) << 29) | ((last) << 31))
// R7xx has alu_inst at a different slot, and no fog merge any more (no fix function fog any more)
#define R6xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, fm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) \
(((s0a) << 0) | ((s1a) << 1) | ((uem) << 2) | ((up) << 3) | ((wm) << 4) | \
((fm) << 5) | ((omod) << 6) | ((alu_inst) << 8) | ((bs) << 18) | ((dst_gpr) << 21) | \
((dr) << 28) | ((de) << 29) | ((clamp) << 31))
#define R7xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) \
(((s0a) << 0) | ((s1a) << 1) | ((uem) << 2) | ((up) << 3) | ((wm) << 4) | \
((omod) << 5) | ((alu_inst) << 7) | ((bs) << 18) | ((dst_gpr) << 21) | \
((dr) << 28) | ((de) << 29) | ((clamp) << 31))
// This is a general chipset macro, but due to selection by chipid typically not usable in static arrays
// Fog is NOT USED on R7xx, even if specified.
#define ALU_DWORD1_OP2(chipfamily, s0a, s1a, uem, up, wm, fm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) \
((chipfamily) < CHIP_FAMILY_RV770 ? \
R6xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, fm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) : \
R7xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, omod, alu_inst, bs, dst_gpr, dr, de, clamp))
#define ALU_DWORD1_OP3(src2_sel, s2r, s2e, s2n, alu_inst, bs, dst_gpr, dr, de, clamp) \
(((src2_sel) << 0) | ((s2r) << 9) | ((s2e) << 10) | ((s2n) << 12) | \
((alu_inst) << 13) | ((bs) << 18) | ((dst_gpr) << 21) | ((dr) << 28) | \
((de) << 29) | ((clamp) << 31))
// VTX clause insts
// vxt insts
#define VTX_INST(x) (x) // SQ_VTX_INST_*
// fetch type
#define FETCH_TYPE(x) (x) // SQ_VTX_FETCH_*
#define FETCH_WHOLE_QUAD(x) (x)
#define BUFFER_ID(x) (x)
#define SRC_GPR(x) (x)
#define SRC_REL(x) (x)
#define MEGA_FETCH_COUNT(x) ((x) ? ((x) - 1) : 0)
#define SEMANTIC_ID(x) (x)
#define DST_SEL_X(x) (x)
#define DST_SEL_Y(x) (x)
#define DST_SEL_Z(x) (x)
#define DST_SEL_W(x) (x)
#define USE_CONST_FIELDS(x) (x)
#define DATA_FORMAT(x) (x)
// num format
#define NUM_FORMAT_ALL(x) (x) // SQ_NUM_FORMAT_*
// format comp
#define FORMAT_COMP_ALL(x) (x) // SQ_FORMAT_COMP_*
// sma
#define SRF_MODE_ALL(x) (x)
#define SRF_MODE_ZERO_CLAMP_MINUS_ONE 0
#define SRF_MODE_NO_ZERO 1
#define OFFSET(x) (x)
// endian swap
#define ENDIAN_SWAP(x) (x) // SQ_ENDIAN_*
#define CONST_BUF_NO_STRIDE(x) (x)
// mf
#define MEGA_FETCH(x) (x)
#define VTX_DWORD0(vtx_inst, ft, fwq, buffer_id, src_gpr, sr, ssx, mfc) \
(((vtx_inst) << 0) | ((ft) << 5) | ((fwq) << 7) | ((buffer_id) << 8) | \
((src_gpr) << 16) | ((sr) << 23) | ((ssx) << 24) | ((mfc) << 26))
#define VTX_DWORD1_SEM(semantic_id, dsx, dsy, dsz, dsw, ucf, data_format, nfa, fca, sma) \
(((semantic_id) << 0) | ((dsx) << 9) | ((dsy) << 12) | ((dsz) << 15) | ((dsw) << 18) | \
((ucf) << 21) | ((data_format) << 22) | ((nfa) << 28) | ((fca) << 30) | ((sma) << 31))
#define VTX_DWORD1_GPR(dst_gpr, dr, dsx, dsy, dsz, dsw, ucf, data_format, nfa, fca, sma) \
(((dst_gpr) << 0) | ((dr) << 7) | ((dsx) << 9) | ((dsy) << 12) | ((dsz) << 15) | ((dsw) << 18) | \
((ucf) << 21) | ((data_format) << 22) | ((nfa) << 28) | ((fca) << 30) | ((sma) << 31))
#define VTX_DWORD2(offset, es, cbns, mf) \
(((offset) << 0) | ((es) << 16) | ((cbns) << 18) | ((mf) << 19))
#define VTX_DWORD_PAD 0x00000000
// TEX clause insts
// tex insts
#define TEX_INST(x) (x) // SQ_TEX_INST_*
#define BC_FRAC_MODE(x) (x)
#define FETCH_WHOLE_QUAD(x) (x)
#define RESOURCE_ID(x) (x)
#define R7xx_ALT_CONST(x) (x)
#define LOD_BIAS(x) (x)
//ct
#define COORD_TYPE_X(x) (x)
#define COORD_TYPE_Y(x) (x)
#define COORD_TYPE_Z(x) (x)
#define COORD_TYPE_W(x) (x)
#define TEX_UNNORMALIZED 0
#define TEX_NORMALIZED 1
#define OFFSET_X(x) (x)
#define OFFSET_Y(x) (x)
#define OFFSET_Z(x) (x)
#define SAMPLER_ID(x) (x)
// R7xx has an additional parameter ALT_CONST. We always expose it, but ALT_CONST is R7xx only
#define TEX_DWORD0(tex_inst, bfm, fwq, resource_id, src_gpr, sr, ac) \
(((tex_inst) << 0) | ((bfm) << 5) | ((fwq) << 7) | ((resource_id) << 8) | \
((src_gpr) << 16) | ((sr) << 23) | ((ac) << 24))
#define TEX_DWORD1(dst_gpr, dr, dsx, dsy, dsz, dsw, lod_bias, ctx, cty, ctz, ctw) \
(((dst_gpr) << 0) | ((dr) << 7) | ((dsx) << 9) | ((dsy) << 12) | ((dsz) << 15) | ((dsw) << 18) | \
((lod_bias) << 21) | ((ctx) << 28) | ((cty) << 29) | ((ctz) << 30) | ((ctw) << 31))
#define TEX_DWORD2(offset_x, offset_y, offset_z, sampler_id, ssx, ssy, ssz, ssw) \
(((offset_x) << 0) | ((offset_y) << 5) | ((offset_z) << 10) | ((sampler_id) << 15) | \
((ssx) << 20) | ((ssy) << 23) | ((ssz) << 26) | ((ssw) << 29))
#define TEX_DWORD_PAD 0x00000000
#endif

227
src/r600_state.h Normal file
View file

@ -0,0 +1,227 @@
#ifndef __R600_STATE_H__
#define __R600_STATE_H__
#include "xf86drm.h"
typedef int bool_t;
/* seriously ?! @#$%% */
# define uint32_t CARD32
# define uint64_t CARD64
#define CLEAR(x) memset (&x, 0, sizeof(x))
/* Sequencer / thread handling */
typedef struct {
int ps_prio;
int vs_prio;
int gs_prio;
int es_prio;
int num_ps_gprs;
int num_vs_gprs;
int num_gs_gprs;
int num_es_gprs;
int num_temp_gprs;
int num_ps_threads;
int num_vs_threads;
int num_gs_threads;
int num_es_threads;
int num_ps_stack_entries;
int num_vs_stack_entries;
int num_gs_stack_entries;
int num_es_stack_entries;
} sq_config_t;
/* Color buffer / render target */
typedef struct {
int id;
int w;
int h;
uint64_t base;
int format;
int endian;
int array_mode; // tiling
int number_type;
int read_size;
int comp_swap;
int tile_mode;
int blend_clamp;
int clear_color;
int blend_bypass;
int blend_float32;
int simple_float;
int round_mode;
int tile_compact;
int source_format;
} cb_config_t;
/* Depth buffer */
typedef struct {
int w;
int h;
uint64_t base;
int format;
int read_size;
int array_mode; // tiling
int tile_surface_en;
int tile_compact;
int zrange_precision;
} db_config_t;
/* Shader */
typedef struct {
uint64_t shader_addr;
int num_gprs;
int stack_size;
int dx10_clamp;
int prime_cache_pgm_en;
int prime_cache_on_draw;
int fetch_cache_lines;
int prime_cache_en;
int prime_cache_on_const;
int clamp_consts;
int export_mode;
int uncached_first_inst;
} shader_config_t;
/* Vertex buffer / vtx resource */
typedef struct {
int id;
uint64_t vb_addr;
uint32_t vtx_num_entries;
uint32_t vtx_size_dw;
int clamp_x;
int format;
int num_format_all;
int format_comp_all;
int srf_mode_all;
int endian;
int mem_req_size;
} vtx_resource_t;
/* Texture resource */
typedef struct {
int id;
int w;
int h;
int pitch;
int depth;
int dim;
int tile_mode;
int tile_type;
int format;
uint64_t base;
uint64_t mip_base;
int format_comp_x;
int format_comp_y;
int format_comp_z;
int format_comp_w;
int num_format_all;
int srf_mode_all;
int force_degamma;
int endian;
int request_size;
int dst_sel_x;
int dst_sel_y;
int dst_sel_z;
int dst_sel_w;
int base_level;
int last_level;
int base_array;
int last_array;
int mpeg_clamp;
int perf_modulation;
int interlaced;
} tex_resource_t;
/* Texture sampler */
typedef struct {
int id;
/* Clamping */
int clamp_x, clamp_y, clamp_z;
int border_color;
/* Filtering */
int xy_mag_filter, xy_min_filter;
int z_filter;
int mip_filter;
bool_t high_precision_filter; /* ? */
int perf_mip; /* ? 0-7 */
int perf_z; /* ? 3 */
/* LoD selection */
int min_lod, max_lod; /* 0-0x3ff */
int lod_bias; /* 0-0xfff (signed?) */
int lod_bias2; /* ? 0-0xfff (signed?) */
bool_t lod_uses_minor_axis; /* ? */
/* Other stuff */
bool_t point_sampling_clamp; /* ? */
bool_t tex_array_override; /* ? */
bool_t mc_coord_truncate; /* ? */
bool_t force_degamma; /* ? */
bool_t fetch_4; /* ? */
bool_t sample_is_pcf; /* ? */
bool_t type; /* ? */
int depth_compare; /* only depth textures? */
int chroma_key;
} tex_sampler_t;
/* Draw command */
typedef struct {
uint32_t prim_type;
uint32_t vgt_draw_initiator;
uint32_t index_type;
uint32_t num_instances;
uint32_t num_indices;
} draw_config_t;
inline void e32(drmBufPtr ib, uint32_t dword);
inline void efloat(drmBufPtr ib, float f);
inline void pack3(drmBufPtr ib, int cmd, unsigned num);
inline void pack0 (drmBufPtr ib, uint32_t reg, int num);
inline void ereg (drmBufPtr ib, uint32_t reg, uint32_t val);
void R600CPFlushIndirect(ScrnInfoPtr pScrn, drmBufPtr ib);
void R600IBDiscard(ScrnInfoPtr pScrn, drmBufPtr ib);
uint64_t
upload (ScrnInfoPtr pScrn, void *shader, int size, int offset);
void
wait_3d_idle_clean(ScrnInfoPtr pScrn, drmBufPtr ib);
void
wait_3d_idle(ScrnInfoPtr pScrn, drmBufPtr ib);
void
start_3d(ScrnInfoPtr pScrn, drmBufPtr ib);
void
set_render_target(ScrnInfoPtr pScrn, drmBufPtr ib, cb_config_t *cb_conf);
void
cp_set_surface_sync(ScrnInfoPtr pScrn, drmBufPtr ib, uint32_t sync_type, uint32_t size, uint64_t mc_addr);
void
fs_setup(ScrnInfoPtr pScrn, drmBufPtr ib, shader_config_t *fs_conf);
void
vs_setup(ScrnInfoPtr pScrn, drmBufPtr ib, shader_config_t *vs_conf);
void
ps_setup(ScrnInfoPtr pScrn, drmBufPtr ib, shader_config_t *ps_conf);
void
set_alu_consts(ScrnInfoPtr pScrn, drmBufPtr ib, int offset, int count, float *const_buf);
void
set_vtx_resource(ScrnInfoPtr pScrn, drmBufPtr ib, vtx_resource_t *res);
void
set_tex_resource(ScrnInfoPtr pScrn, drmBufPtr ib, tex_resource_t *tex_res);
void
set_tex_sampler (ScrnInfoPtr pScrn, drmBufPtr ib, tex_sampler_t *s);
void
set_screen_scissor(ScrnInfoPtr pScrn, drmBufPtr ib, int x1, int y1, int x2, int y2);
void
set_vport_scissor(ScrnInfoPtr pScrn, drmBufPtr ib, int id, int x1, int y1, int x2, int y2);
void
set_generic_scissor(ScrnInfoPtr pScrn, drmBufPtr ib, int x1, int y1, int x2, int y2);
void
set_window_scissor(ScrnInfoPtr pScrn, drmBufPtr ib, int x1, int y1, int x2, int y2);
void
set_clip_rect(ScrnInfoPtr pScrn, drmBufPtr ib, int id, int x1, int y1, int x2, int y2);
void
set_default_state(ScrnInfoPtr pScrn, drmBufPtr ib);
void
draw_immd(ScrnInfoPtr pScrn, drmBufPtr ib, draw_config_t *draw_conf, uint32_t *indices);
void
draw_auto(ScrnInfoPtr pScrn, drmBufPtr ib, draw_config_t *draw_conf);
#endif

View file

@ -0,0 +1,374 @@
/*
* Copyright 2008 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Author: Alex Deucher <alexander.deucher@amd.com>
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xf86.h"
#include "exa.h"
#include "radeon.h"
#include "r600_shader.h"
#include "r600_reg.h"
#include "r600_state.h"
#include "radeon_video.h"
#include <X11/extensions/Xv.h>
#include "fourcc.h"
#include "damage.h"
void
R600DisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
struct radeon_accel_state *accel_state = info->accel_state;
PixmapPtr pPixmap = pPriv->pPixmap;
BoxPtr pBox = REGION_RECTS(&pPriv->clip);
int nBox = REGION_NUM_RECTS(&pPriv->clip);
int dstxoff, dstyoff;
cb_config_t cb_conf;
tex_resource_t tex_res;
tex_sampler_t tex_samp;
shader_config_t vs_conf, ps_conf;
draw_config_t draw_conf;
vtx_resource_t vtx_res;
int uv_offset;
static float ps_alu_consts[] = {
1.0, 0.0, 1.13983, -1.13983/2, // r - c[0]
1.0, -0.39465, -0.5806, (0.39465+0.5806)/2, // g - c[1]
1.0, 2.03211, 0.0, -2.03211/2, // b - c[2]
};
CLEAR (cb_conf);
CLEAR (tex_res);
CLEAR (tex_samp);
CLEAR (vs_conf);
CLEAR (ps_conf);
CLEAR (draw_conf);
CLEAR (vtx_res);
accel_state->dst_pitch = exaGetPixmapPitch(pPixmap) / (pPixmap->drawable.bitsPerPixel / 8);
accel_state->src_pitch[0] = pPriv->src_pitch;
// bad pitch
if (accel_state->src_pitch[0] & 7)
return;
if (accel_state->dst_pitch & 7)
return;
#ifdef COMPOSITE
dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
dstyoff = -pPixmap->screen_y + pPixmap->drawable.y;
#else
dstxoff = 0;
dstyoff = 0;
#endif
accel_state->ib = RADEONCPGetBuffer(pScrn);
/* Init */
start_3d(pScrn, accel_state->ib);
//cp_set_surface_sync(pScrn, accel_state->ib);
set_default_state(pScrn, accel_state->ib);
/* Scissor / viewport */
ereg (accel_state->ib, PA_CL_VTE_CNTL, VTX_XY_FMT_bit);
ereg (accel_state->ib, PA_CL_CLIP_CNTL, CLIP_DISABLE_bit);
accel_state->vs_mc_addr = info->fbLocation + pScrn->fbOffset + accel_state->shaders->offset +
accel_state->xv_vs_offset;
accel_state->ps_mc_addr = info->fbLocation + pScrn->fbOffset + accel_state->shaders->offset +
accel_state->xv_ps_offset;
accel_state->vs_size = 512;
accel_state->ps_size = 512;
/* Shader */
/* flush SQ cache */
cp_set_surface_sync(pScrn, accel_state->ib, SH_ACTION_ENA_bit,
accel_state->vs_size, accel_state->vs_mc_addr);
vs_conf.shader_addr = accel_state->vs_mc_addr;
vs_conf.num_gprs = 2;
vs_conf.stack_size = 0;
vs_setup (pScrn, accel_state->ib, &vs_conf);
/* flush SQ cache */
cp_set_surface_sync(pScrn, accel_state->ib, SH_ACTION_ENA_bit,
accel_state->ps_size, accel_state->ps_mc_addr);
ps_conf.shader_addr = accel_state->ps_mc_addr;
ps_conf.num_gprs = 4;
ps_conf.stack_size = 0;
ps_conf.uncached_first_inst = 1;
ps_conf.clamp_consts = 0;
ps_conf.export_mode = 2;
ps_setup (pScrn, accel_state->ib, &ps_conf);
// PS alu constants
set_alu_consts(pScrn, accel_state->ib, 0, sizeof(ps_alu_consts) / SQ_ALU_CONSTANT_offset, ps_alu_consts);
/* Texture */
accel_state->src_mc_addr[0] = pPriv->src_offset;
accel_state->src_size[0] = exaGetPixmapPitch(pPixmap) * pPriv->w;
/* flush texture cache */
cp_set_surface_sync(pScrn, accel_state->ib, TC_ACTION_ENA_bit, 512,
accel_state->src_mc_addr[0]);
// Y texture
tex_res.id = 0;
tex_res.w = pPriv->w;
tex_res.h = pPriv->h;
tex_res.pitch = accel_state->src_pitch[0];
tex_res.depth = 0;
tex_res.dim = SQ_TEX_DIM_2D;
tex_res.base = accel_state->src_mc_addr[0];
tex_res.mip_base = accel_state->src_mc_addr[0];
tex_res.format = FMT_8;
tex_res.dst_sel_x = SQ_SEL_X; //Y
tex_res.dst_sel_y = SQ_SEL_1;
tex_res.dst_sel_z = SQ_SEL_1;
tex_res.dst_sel_w = SQ_SEL_1;
tex_res.request_size = 1;
tex_res.base_level = 0;
tex_res.last_level = 0;
tex_res.perf_modulation = 0;
tex_res.interlaced = 0;
set_tex_resource (pScrn, accel_state->ib, &tex_res);
// UV texture
uv_offset = accel_state->src_pitch[0] * pPriv->h;
uv_offset = (uv_offset + 255) & ~255;
cp_set_surface_sync(pScrn, accel_state->ib, TC_ACTION_ENA_bit,
accel_state->src_size[0] / 2,
accel_state->src_mc_addr[0] + uv_offset);
tex_res.id = 1;
tex_res.format = FMT_8_8;
tex_res.w = pPriv->w >> 1;
tex_res.h = pPriv->h >> 1;
tex_res.pitch = accel_state->src_pitch[0] >> 1;
tex_res.dst_sel_x = SQ_SEL_Y; //V
tex_res.dst_sel_y = SQ_SEL_X; //U
tex_res.dst_sel_z = SQ_SEL_1;
tex_res.dst_sel_w = SQ_SEL_1;
tex_res.interlaced = 0;
// XXX tex bases need to be 256B aligned
tex_res.base = accel_state->src_mc_addr[0] + uv_offset;
tex_res.mip_base = accel_state->src_mc_addr[0] + uv_offset;
set_tex_resource (pScrn, accel_state->ib, &tex_res);
// Y sampler
tex_samp.id = 0;
tex_samp.clamp_x = SQ_TEX_CLAMP_LAST_TEXEL;
tex_samp.clamp_y = SQ_TEX_CLAMP_LAST_TEXEL;
tex_samp.clamp_z = SQ_TEX_WRAP;
// xxx: switch to bicubic
tex_samp.xy_mag_filter = SQ_TEX_XY_FILTER_BILINEAR;
tex_samp.xy_min_filter = SQ_TEX_XY_FILTER_BILINEAR;
tex_samp.z_filter = SQ_TEX_Z_FILTER_NONE;
tex_samp.mip_filter = 0; /* no mipmap */
set_tex_sampler (pScrn, accel_state->ib, &tex_samp);
// UV sampler
tex_samp.id = 1;
set_tex_sampler (pScrn, accel_state->ib, &tex_samp);
/* Render setup */
ereg (accel_state->ib, CB_SHADER_MASK, (0x0f << OUTPUT0_ENABLE_shift));
ereg (accel_state->ib, R7xx_CB_SHADER_CONTROL, (RT0_ENABLE_bit));
ereg (accel_state->ib, CB_COLOR_CONTROL, (0xcc << ROP3_shift)); /* copy */
cb_conf.id = 0;
accel_state->dst_mc_addr = exaGetPixmapOffset(pPixmap) + info->fbLocation + pScrn->fbOffset;
cb_conf.w = accel_state->dst_pitch;
cb_conf.h = pPixmap->drawable.height;
cb_conf.base = accel_state->dst_mc_addr;
switch (pPixmap->drawable.bitsPerPixel) {
case 16:
if (pPixmap->drawable.depth == 15) {
cb_conf.format = COLOR_1_5_5_5;
cb_conf.comp_swap = 1; //ARGB
} else {
cb_conf.format = COLOR_5_6_5;
cb_conf.comp_swap = 2; //RGB
}
break;
case 32:
cb_conf.format = COLOR_8_8_8_8;
cb_conf.comp_swap = 1; //ARGB
break;
default:
return;
}
cb_conf.source_format = 1;
cb_conf.blend_clamp = 1;
set_render_target(pScrn, accel_state->ib, &cb_conf);
ereg (accel_state->ib, PA_SU_SC_MODE_CNTL, (FACE_bit |
(POLYMODE_PTYPE__TRIANGLES << POLYMODE_FRONT_PTYPE_shift) |
(POLYMODE_PTYPE__TRIANGLES << POLYMODE_BACK_PTYPE_shift)));
ereg (accel_state->ib, DB_SHADER_CONTROL, ((1 << Z_ORDER_shift) | /* EARLY_Z_THEN_LATE_Z */
DUAL_EXPORT_ENABLE_bit)); /* Only useful if no depth export */
/* Interpolator setup */
// export tex coords from VS
ereg (accel_state->ib, SPI_VS_OUT_CONFIG, ((1 - 1) << VS_EXPORT_COUNT_shift));
ereg (accel_state->ib, SPI_VS_OUT_ID_0, (0 << SEMANTIC_0_shift));
/* Enabling flat shading needs both FLAT_SHADE_bit in SPI_PS_INPUT_CNTL_x
* *and* FLAT_SHADE_ENA_bit in SPI_INTERP_CONTROL_0 */
ereg (accel_state->ib, SPI_PS_IN_CONTROL_0, ((1 << NUM_INTERP_shift)));
ereg (accel_state->ib, SPI_PS_IN_CONTROL_1, 0);
ereg (accel_state->ib, SPI_PS_INPUT_CNTL_0 + (0 <<2), ((0 << SEMANTIC_shift) |
(0x03 << DEFAULT_VAL_shift) |
SEL_CENTROID_bit));
ereg (accel_state->ib, SPI_INTERP_CONTROL_0, 0);
accel_state->vb_index = 0;
while (nBox--) {
int srcX, srcY, srcw, srch;
int dstX, dstY, dstw, dsth;
struct r6xx_copy_vertex *xv_vb = (pointer)((char*)accel_state->ib->address + (accel_state->ib->total / 2));
struct r6xx_copy_vertex vertex[3];
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
dstw = pBox->x2 - pBox->x1;
dsth = pBox->y2 - pBox->y1;
srcX = ((pBox->x1 - pPriv->drw_x) *
pPriv->src_w) / pPriv->dst_w;
srcY = ((pBox->y1 - pPriv->drw_y) *
pPriv->src_h) / pPriv->dst_h;
srcw = (pPriv->src_w * dstw) / pPriv->dst_w;
srch = (pPriv->src_h * dsth) / pPriv->dst_h;
vertex[0].x = (float)dstX;
vertex[0].y = (float)dstY;
vertex[0].s = (float)srcX / pPriv->w;
vertex[0].t = (float)srcY / pPriv->h;
vertex[1].x = (float)dstX;
vertex[1].y = (float)(dstY + dsth);
vertex[1].s = (float)srcX / pPriv->w;
vertex[1].t = (float)(srcY + srch) / pPriv->h;
vertex[2].x = (float)(dstX + dstw);
vertex[2].y = (float)(dstY + dsth);
vertex[2].s = (float)(srcX + srcw) / pPriv->w;
vertex[2].t = (float)(srcY + srch) / pPriv->h;
#if 0
ErrorF("vertex 0: %f, %f, %f, %f\n", vertex[0].x, vertex[0].y, vertex[0].s, vertex[0].t);
ErrorF("vertex 1: %f, %f, %f, %f\n", vertex[1].x, vertex[1].y, vertex[1].s, vertex[1].t);
ErrorF("vertex 2: %f, %f, %f, %f\n", vertex[2].x, vertex[2].y, vertex[2].s, vertex[2].t);
#endif
// append to vertex buffer
xv_vb[accel_state->vb_index++] = vertex[0];
xv_vb[accel_state->vb_index++] = vertex[1];
xv_vb[accel_state->vb_index++] = vertex[2];
pBox++;
}
if (accel_state->vb_index == 0) {
R600IBDiscard(pScrn, accel_state->ib);
DamageDamageRegion(pPriv->pDraw, &pPriv->clip);
return;
}
accel_state->vb_mc_addr = info->gartLocation + info->dri->bufStart +
(accel_state->ib->idx * accel_state->ib->total) + (accel_state->ib->total / 2);
accel_state->vb_size = accel_state->vb_index * 16;
/* flush vertex cache */
if ((info->ChipFamily == CHIP_FAMILY_RV610) ||
(info->ChipFamily == CHIP_FAMILY_RV620) ||
(info->ChipFamily == CHIP_FAMILY_RS780) ||
(info->ChipFamily == CHIP_FAMILY_RV710))
cp_set_surface_sync(pScrn, accel_state->ib, TC_ACTION_ENA_bit,
accel_state->vb_size, accel_state->vb_mc_addr);
else
cp_set_surface_sync(pScrn, accel_state->ib, VC_ACTION_ENA_bit,
accel_state->vb_size, accel_state->vb_mc_addr);
/* Vertex buffer setup */
vtx_res.id = SQ_VTX_RESOURCE_vs;
vtx_res.vtx_size_dw = 16 / 4;
vtx_res.vtx_num_entries = accel_state->vb_size / 4;
vtx_res.mem_req_size = 1;
vtx_res.vb_addr = accel_state->vb_mc_addr;
set_vtx_resource (pScrn, accel_state->ib, &vtx_res);
draw_conf.prim_type = DI_PT_RECTLIST;
draw_conf.vgt_draw_initiator = DI_SRC_SEL_AUTO_INDEX;
draw_conf.num_instances = 1;
draw_conf.num_indices = vtx_res.vtx_num_entries / vtx_res.vtx_size_dw;
draw_conf.index_type = DI_INDEX_SIZE_16_BIT;
ereg (accel_state->ib, VGT_INSTANCE_STEP_RATE_0, 0); /* ? */
ereg (accel_state->ib, VGT_INSTANCE_STEP_RATE_1, 0);
ereg (accel_state->ib, VGT_MAX_VTX_INDX, draw_conf.num_indices);
ereg (accel_state->ib, VGT_MIN_VTX_INDX, 0);
ereg (accel_state->ib, VGT_INDX_OFFSET, 0);
draw_auto(pScrn, accel_state->ib, &draw_conf);
wait_3d_idle_clean(pScrn, accel_state->ib);
/* sync destination surface */
cp_set_surface_sync(pScrn, accel_state->ib, (CB_ACTION_ENA_bit, CB0_DEST_BASE_ENA_bit),
accel_state->dst_size, accel_state->dst_mc_addr);
R600CPFlushIndirect(pScrn, accel_state->ib);
DamageDamageRegion(pPriv->pDraw, &pPriv->clip);
}

1110
src/r6xx_accel.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -354,6 +354,8 @@ typedef enum {
#define IS_DCE32_VARIANT ((info->ChipFamily >= CHIP_FAMILY_RV730))
#define IS_R600_3D (info->ChipFamily >= CHIP_FAMILY_R600)
#define IS_R500_3D ((info->ChipFamily == CHIP_FAMILY_RV515) || \
(info->ChipFamily == CHIP_FAMILY_R520) || \
(info->ChipFamily == CHIP_FAMILY_RV530) || \
@ -569,6 +571,38 @@ struct radeon_dri {
};
#endif
#ifdef XF86DRI
#ifdef USE_EXA
struct r6xx_solid_vertex {
float x;
float y;
};
struct r6xx_copy_vertex {
float x;
float y;
float s;
float t;
};
struct r6xx_comp_vertex {
float x;
float y;
float src_s;
float src_t;
};
struct r6xx_comp_mask_vertex {
float x;
float y;
float src_s;
float src_t;
float mask_s;
float mask_t;
};
#endif
#endif
struct radeon_accel_state {
/* common accel data */
int fifo_slots; /* Free slots in the FIFO (64 max) */
@ -609,6 +643,44 @@ struct radeon_accel_state {
Bool src_tile_height;
Bool vsync;
drmBufPtr ib;
int vb_index;
// shader storage
ExaOffscreenArea *shaders;
uint32_t solid_vs_offset;
uint32_t solid_ps_offset;
uint32_t copy_vs_offset;
uint32_t copy_ps_offset;
uint32_t comp_vs_offset;
uint32_t comp_ps_offset;
uint32_t comp_mask_vs_offset;
uint32_t comp_mask_ps_offset;
uint32_t xv_vs_offset;
uint32_t xv_ps_offset;
//size/addr stuff
uint32_t src_size[2];
uint64_t src_mc_addr[2];
uint32_t src_pitch[2];
uint32_t dst_size;
uint64_t dst_mc_addr;
uint32_t dst_pitch;
uint32_t vs_size;
uint64_t vs_mc_addr;
uint32_t ps_size;
uint64_t ps_mc_addr;
uint32_t vb_size;
uint64_t vb_mc_addr;
// UTS/DFS
drmBufPtr scratch;
// copy
Bool same_surface;
int rop;
uint32_t planemask;
#endif
#ifdef USE_XAA
@ -1032,6 +1104,7 @@ extern void RADEONDoPrepareCopyMMIO(ScrnInfoPtr pScrn,
uint32_t dst_pitch_offset,
uint32_t datatype, int rop,
Pixel planemask);
extern Bool R600DrawInit(ScreenPtr pScreen);
#endif
#if defined(XF86DRI) && defined(USE_EXA)
@ -1116,15 +1189,16 @@ do { \
#define RADEONCP_STOP(pScrn, info) \
do { \
int _ret; \
if (info->cp->CPStarted) { \
if (info->cp->CPStarted) { \
_ret = RADEONCPStop(pScrn, info); \
if (_ret) { \
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \
"%s: CP stop %d\n", __FUNCTION__, _ret); \
} \
info->cp->CPStarted = FALSE; \
} \
RADEONEngineRestore(pScrn); \
} \
if (info->ChipFamily < CHIP_FAMILY_R600) \
RADEONEngineRestore(pScrn); \
info->cp->CPRuns = FALSE; \
} while (0)
@ -1240,19 +1314,26 @@ do { \
#define RADEON_WAIT_UNTIL_2D_IDLE() \
do { \
BEGIN_RING(2); \
OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \
RADEON_WAIT_HOST_IDLECLEAN)); \
ADVANCE_RING(); \
if (info->ChipFamily < CHIP_FAMILY_R600) { \
BEGIN_RING(2); \
OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \
RADEON_WAIT_HOST_IDLECLEAN)); \
ADVANCE_RING(); \
} \
} while (0)
#define RADEON_WAIT_UNTIL_3D_IDLE() \
do { \
BEGIN_RING(2); \
OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_3D_IDLECLEAN | \
RADEON_WAIT_HOST_IDLECLEAN)); \
if (info->ChipFamily >= CHIP_FAMILY_R600) { \
OUT_RING(CP_PACKET0(R600_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_3D_IDLECLEAN)); \
} else { \
OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_3D_IDLECLEAN | \
RADEON_WAIT_HOST_IDLECLEAN)); \
} \
ADVANCE_RING(); \
} while (0)
@ -1263,17 +1344,25 @@ do { \
"WAIT_UNTIL_IDLE() in %s\n", __FUNCTION__); \
} \
BEGIN_RING(2); \
OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \
RADEON_WAIT_3D_IDLECLEAN | \
RADEON_WAIT_HOST_IDLECLEAN)); \
if (info->ChipFamily >= CHIP_FAMILY_R600) { \
OUT_RING(CP_PACKET0(R600_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_3D_IDLECLEAN)); \
} else { \
OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \
OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \
RADEON_WAIT_3D_IDLECLEAN | \
RADEON_WAIT_HOST_IDLECLEAN)); \
} \
ADVANCE_RING(); \
} while (0)
#define RADEON_PURGE_CACHE() \
do { \
BEGIN_RING(2); \
if (info->ChipFamily <= CHIP_FAMILY_RV280) { \
if (info->ChipFamily >= CHIP_FAMILY_R600) { \
OUT_RING(CP_PACKET3(IT_EVENT_WRITE, 0)); \
OUT_RING(CACHE_FLUSH_AND_INV_EVENT); \
} else if (info->ChipFamily <= CHIP_FAMILY_RV280) { \
OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \
OUT_RING(RADEON_RB3D_DC_FLUSH_ALL); \
} else { \
@ -1285,15 +1374,17 @@ do { \
#define RADEON_PURGE_ZCACHE() \
do { \
BEGIN_RING(2); \
if (info->ChipFamily <= CHIP_FAMILY_RV280) { \
OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \
OUT_RING(RADEON_RB3D_ZC_FLUSH_ALL); \
} else { \
OUT_RING(CP_PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0)); \
OUT_RING(R300_ZC_FLUSH_ALL); \
if (info->ChipFamily < CHIP_FAMILY_R600) { \
BEGIN_RING(2); \
if (info->ChipFamily <= CHIP_FAMILY_RV280) { \
OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \
OUT_RING(RADEON_RB3D_ZC_FLUSH_ALL); \
} else { \
OUT_RING(CP_PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0)); \
OUT_RING(R300_ZC_FLUSH_ALL); \
} \
ADVANCE_RING(); \
} \
ADVANCE_RING(); \
} while (0)
#endif /* XF86DRI */

View file

@ -78,6 +78,7 @@
/* Driver data structures */
#include "radeon.h"
#include "radeon_reg.h"
#include "r600_reg.h"
#include "radeon_macros.h"
#include "radeon_probe.h"
#include "radeon_version.h"
@ -156,9 +157,6 @@ void RADEONEngineFlush(ScrnInfoPtr pScrn)
unsigned char *RADEONMMIO = info->MMIO;
int i;
if (info->ChipFamily >= CHIP_FAMILY_R600)
return;
if (info->ChipFamily <= CHIP_FAMILY_RV280) {
OUTREGP(RADEON_RB3D_DSTCACHE_CTLSTAT,
RADEON_RB3D_DC_FLUSH_ALL,
@ -198,8 +196,6 @@ void RADEONEngineReset(ScrnInfoPtr pScrn)
uint32_t rbbm_soft_reset;
uint32_t host_path_cntl;
if (info->ChipFamily >= CHIP_FAMILY_R600)
return;
/* The following RBBM_SOFT_RESET sequence can help un-wedge
* an R300 after the command processor got stuck.
*/
@ -310,6 +306,35 @@ void RADEONEngineReset(ScrnInfoPtr pScrn)
OUTPLL(pScrn, RADEON_MCLK_CNTL, mclk_cntl);
}
/* Reset graphics card to known state */
void R600EngineReset(ScrnInfoPtr pScrn)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
uint32_t cp_ptr, cp_me_cntl, cp_rb_cntl;
cp_ptr = INREG(R600_CP_RB_WPTR);
cp_me_cntl = INREG(R600_CP_ME_CNTL);
OUTREG(R600_CP_ME_CNTL, 0x10000000);
OUTREG(R600_GRBM_SOFT_RESET, 0x7fff);
INREG(R600_GRBM_SOFT_RESET);
usleep (50);
OUTREG(R600_GRBM_SOFT_RESET, 0);
INREG(R600_GRBM_SOFT_RESET);
OUTREG(R600_CP_RB_WPTR_DELAY, 0);
cp_rb_cntl = INREG(R600_CP_RB_CNTL);
OUTREG(R600_CP_RB_CNTL, 0x80000000);
OUTREG(R600_CP_RB_RPTR_WR, cp_ptr);
OUTREG(R600_CP_RB_WPTR, cp_ptr);
OUTREG(R600_CP_RB_CNTL, cp_rb_cntl);
OUTREG(R600_CP_ME_CNTL, cp_me_cntl);
}
/* Restore the acceleration hardware to its previous state */
void RADEONEngineRestore(ScrnInfoPtr pScrn)
{
@ -611,8 +636,12 @@ drmBufPtr RADEONCPGetBuffer(ScrnInfoPtr pScrn)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"GetBuffer timed out, resetting engine...\n");
RADEONEngineReset(pScrn);
RADEONEngineRestore(pScrn);
if (info->ChipFamily < CHIP_FAMILY_R600) {
RADEONEngineReset(pScrn);
RADEONEngineRestore(pScrn);
} else
R600EngineReset(pScrn);
/* Always restart the engine when doing CP 2D acceleration */
RADEONCP_RESET(pScrn, info);
@ -627,6 +656,8 @@ void RADEONCPFlushIndirect(ScrnInfoPtr pScrn, int discard)
drmBufPtr buffer = info->cp->indirectBuffer;
int start = info->cp->indirectStart;
drm_radeon_indirect_t indirect;
RING_LOCALS;
RADEONCP_REFRESH(pScrn, info);
if (!buffer) return;
if (start == buffer->used && !discard) return;
@ -636,6 +667,14 @@ void RADEONCPFlushIndirect(ScrnInfoPtr pScrn, int discard)
buffer->idx);
}
if (info->ChipFamily >= CHIP_FAMILY_R600) {
while (buffer->used & 0x3c){
BEGIN_RING(1);
OUT_RING(CP_PACKET2()); /* fill up to multiple of 16 dwords */
ADVANCE_RING();
}
}
indirect.idx = buffer->idx;
indirect.start = start;
indirect.end = buffer->used;
@ -664,6 +703,19 @@ void RADEONCPReleaseIndirect(ScrnInfoPtr pScrn)
drmBufPtr buffer = info->cp->indirectBuffer;
int start = info->cp->indirectStart;
drm_radeon_indirect_t indirect;
RING_LOCALS;
RADEONCP_REFRESH(pScrn, info);
if (info->ChipFamily >= CHIP_FAMILY_R600) {
if (buffer) {
while (buffer->used & 0x3c) {
BEGIN_RING(1);
OUT_RING(CP_PACKET2()); /* fill up to multiple of 16 dwords */
ADVANCE_RING();
}
}
}
info->cp->indirectBuffer = NULL;
info->cp->indirectStart = 0;
@ -926,20 +978,26 @@ Bool RADEONAccelInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
RADEONInfoPtr info = RADEONPTR(pScrn);
if (info->ChipFamily >= CHIP_FAMILY_R600)
return FALSE;
#ifdef USE_EXA
if (info->useEXA) {
# ifdef XF86DRI
if (info->directRenderingEnabled) {
if (!RADEONDrawInitCP(pScreen))
return FALSE;
if (info->ChipFamily >= CHIP_FAMILY_R600) {
if (!R600DrawInit(pScreen))
return FALSE;
} else {
if (!RADEONDrawInitCP(pScreen))
return FALSE;
}
} else
# endif /* XF86DRI */
{
if (!RADEONDrawInitMMIO(pScreen))
if (info->ChipFamily >= CHIP_FAMILY_R600)
return FALSE;
else {
if (!RADEONDrawInitMMIO(pScreen))
return FALSE;
}
}
}
#endif /* USE_EXA */
@ -947,6 +1005,9 @@ Bool RADEONAccelInit(ScreenPtr pScreen)
if (!info->useEXA) {
XAAInfoRecPtr a;
if (info->ChipFamily >= CHIP_FAMILY_R600)
return FALSE;
if (!(a = info->accel_state->accel = XAACreateInfoRec())) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "XAACreateInfoRec Error\n");
return FALSE;

View file

@ -733,8 +733,11 @@ void FUNC_NAME(RADEONWaitForIdle)(ScrnInfoPtr pScrn)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Idle timed out, resetting engine...\n");
RADEONEngineReset(pScrn);
RADEONEngineRestore(pScrn);
if (info->ChipFamily < CHIP_FAMILY_R600) {
RADEONEngineReset(pScrn);
RADEONEngineRestore(pScrn);
} else
R600EngineReset(pScrn);
/* Always restart the engine when doing CP 2D acceleration */
RADEONCP_RESET(pScrn, info);
@ -751,7 +754,7 @@ void FUNC_NAME(RADEONWaitForIdle)(ScrnInfoPtr pScrn)
#endif
if (info->ChipFamily >= CHIP_FAMILY_R600)
return;
return;
/* Wait for the engine to go idle */
RADEONWaitForFifoFunction(pScrn, 64);

View file

@ -45,6 +45,7 @@
#include "radeon.h"
#include "radeon_video.h"
#include "radeon_reg.h"
#include "r600_reg.h"
#include "radeon_macros.h"
#include "radeon_drm.h"
#include "radeon_dri.h"
@ -784,92 +785,96 @@ static Bool RADEONSetAgpMode(RADEONInfoPtr info, ScreenPtr pScreen)
unsigned long mode = drmAgpGetMode(info->dri->drmFD); /* Default mode */
unsigned int vendor = drmAgpVendorId(info->dri->drmFD);
unsigned int device = drmAgpDeviceId(info->dri->drmFD);
/* ignore agp 3.0 mode bit from the chip as it's buggy on some cards with
pcie-agp rialto bridge chip - use the one from bridge which must match */
uint32_t agp_status = (INREG(RADEON_AGP_STATUS) | RADEON_AGPv3_MODE) & mode;
Bool is_v3 = (agp_status & RADEON_AGPv3_MODE);
unsigned int defaultMode;
MessageType from;
if (is_v3) {
defaultMode = (agp_status & RADEON_AGPv3_8X_MODE) ? 8 : 4;
} else {
if (agp_status & RADEON_AGP_4X_MODE) defaultMode = 4;
else if (agp_status & RADEON_AGP_2X_MODE) defaultMode = 2;
else defaultMode = 1;
}
if (info->ChipFamily < CHIP_FAMILY_R600) {
/* ignore agp 3.0 mode bit from the chip as it's buggy on some cards with
pcie-agp rialto bridge chip - use the one from bridge which must match */
uint32_t agp_status = (INREG(RADEON_AGP_STATUS) | RADEON_AGPv3_MODE) & mode;
Bool is_v3 = (agp_status & RADEON_AGPv3_MODE);
unsigned int defaultMode;
MessageType from;
/* Apply AGPMode Quirks */
radeon_agpmode_quirk_ptr p = radeon_agpmode_quirk_list;
while (p && p->chipDevice != 0) {
if (vendor == p->hostbridgeVendor &&
device == p->hostbridgeDevice &&
PCI_DEV_VENDOR_ID(info->PciInfo) == p->chipVendor &&
PCI_DEV_DEVICE_ID(info->PciInfo) == p->chipDevice &&
PCI_SUB_VENDOR_ID(info->PciInfo) == p->subsysVendor &&
PCI_SUB_DEVICE_ID(info->PciInfo) == p->subsysDevice)
{
defaultMode = p->defaultMode;
}
++p;
}
if (is_v3) {
defaultMode = (agp_status & RADEON_AGPv3_8X_MODE) ? 8 : 4;
} else {
if (agp_status & RADEON_AGP_4X_MODE) defaultMode = 4;
else if (agp_status & RADEON_AGP_2X_MODE) defaultMode = 2;
else defaultMode = 1;
}
from = X_DEFAULT;
/* Apply AGPMode Quirks */
radeon_agpmode_quirk_ptr p = radeon_agpmode_quirk_list;
while (p && p->chipDevice != 0) {
if (vendor == p->hostbridgeVendor &&
device == p->hostbridgeDevice &&
PCI_DEV_VENDOR_ID(info->PciInfo) == p->chipVendor &&
PCI_DEV_DEVICE_ID(info->PciInfo) == p->chipDevice &&
PCI_SUB_VENDOR_ID(info->PciInfo) == p->subsysVendor &&
PCI_SUB_DEVICE_ID(info->PciInfo) == p->subsysDevice)
{
defaultMode = p->defaultMode;
}
++p;
}
if (xf86GetOptValInteger(info->Options, OPTION_AGP_MODE, &info->dri->agpMode)) {
if ((info->dri->agpMode < (is_v3 ? 4 : 1)) ||
(info->dri->agpMode > (is_v3 ? 8 : 4)) ||
(info->dri->agpMode & (info->dri->agpMode - 1))) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
"Illegal AGP Mode: %d (valid values: %s), leaving at "
"%dx\n", info->dri->agpMode, is_v3 ? "4, 8" : "1, 2, 4",
defaultMode);
info->dri->agpMode = defaultMode;
from = X_DEFAULT;
if (xf86GetOptValInteger(info->Options, OPTION_AGP_MODE, &info->dri->agpMode)) {
if ((info->dri->agpMode < (is_v3 ? 4 : 1)) ||
(info->dri->agpMode > (is_v3 ? 8 : 4)) ||
(info->dri->agpMode & (info->dri->agpMode - 1))) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
"Illegal AGP Mode: %d (valid values: %s), leaving at "
"%dx\n", info->dri->agpMode, is_v3 ? "4, 8" : "1, 2, 4",
defaultMode);
info->dri->agpMode = defaultMode;
} else
from = X_CONFIG;
} else
from = X_CONFIG;
info->dri->agpMode = defaultMode;
xf86DrvMsg(pScreen->myNum, from, "Using AGP %dx\n", info->dri->agpMode);
mode &= ~RADEON_AGP_MODE_MASK;
if (is_v3) {
/* only set one mode bit for AGPv3 */
switch (info->dri->agpMode) {
case 8: mode |= RADEON_AGPv3_8X_MODE; break;
case 4: default: mode |= RADEON_AGPv3_4X_MODE;
}
/*TODO: need to take care of other bits valid for v3 mode
* currently these bits are not used in all tested cards.
*/
} else {
switch (info->dri->agpMode) {
case 4: mode |= RADEON_AGP_4X_MODE;
case 2: mode |= RADEON_AGP_2X_MODE;
case 1: default: mode |= RADEON_AGP_1X_MODE;
}
}
/* AGP Fast Writes.
* TODO: take into account that certain agp modes don't support fast
* writes at all */
mode &= ~RADEON_AGP_FW_MODE; /* Disable per default */
if (xf86ReturnOptValBool(info->Options, OPTION_AGP_FW, FALSE)) {
xf86DrvMsg(pScreen->myNum, X_WARNING,
"WARNING: Using the AGPFastWrite option is not recommended.\n");
xf86Msg(X_NONE, "\tThis option does not provide much of a noticable speed"
" boost, while it\n\twill probably hard lock your machine."
" All bets are off!\n");
/* Black list some host/AGP bridges. */
if ((vendor == PCI_VENDOR_AMD) && (device == PCI_CHIP_AMD761))
xf86DrvMsg(pScreen->myNum, X_PROBED, "Ignoring AGPFastWrite option "
"for the AMD 761 northbridge.\n");
else {
xf86DrvMsg(pScreen->myNum, X_CONFIG, "Enabling AGP Fast Writes.\n");
mode |= RADEON_AGP_FW_MODE;
}
} /* Don't mention this otherwise, so that people don't get funny ideas */
} else
info->dri->agpMode = defaultMode;
xf86DrvMsg(pScreen->myNum, from, "Using AGP %dx\n", info->dri->agpMode);
mode &= ~RADEON_AGP_MODE_MASK;
if (is_v3) {
/* only set one mode bit for AGPv3 */
switch (info->dri->agpMode) {
case 8: mode |= RADEON_AGPv3_8X_MODE; break;
case 4: default: mode |= RADEON_AGPv3_4X_MODE;
}
/*TODO: need to take care of other bits valid for v3 mode
* currently these bits are not used in all tested cards.
*/
} else {
switch (info->dri->agpMode) {
case 4: mode |= RADEON_AGP_4X_MODE;
case 2: mode |= RADEON_AGP_2X_MODE;
case 1: default: mode |= RADEON_AGP_1X_MODE;
}
}
/* AGP Fast Writes.
* TODO: take into account that certain agp modes don't support fast
* writes at all */
mode &= ~RADEON_AGP_FW_MODE; /* Disable per default */
if (xf86ReturnOptValBool(info->Options, OPTION_AGP_FW, FALSE)) {
xf86DrvMsg(pScreen->myNum, X_WARNING,
"WARNING: Using the AGPFastWrite option is not recommended.\n");
xf86Msg(X_NONE, "\tThis option does not provide much of a noticable speed"
" boost, while it\n\twill probably hard lock your machine."
" All bets are off!\n");
/* Black list some host/AGP bridges. */
if ((vendor == PCI_VENDOR_AMD) && (device == PCI_CHIP_AMD761))
xf86DrvMsg(pScreen->myNum, X_PROBED, "Ignoring AGPFastWrite option "
"for the AMD 761 northbridge.\n");
else {
xf86DrvMsg(pScreen->myNum, X_CONFIG, "Enabling AGP Fast Writes.\n");
mode |= RADEON_AGP_FW_MODE;
}
} /* Don't mention this otherwise, so that people don't get funny ideas */
info->dri->agpMode = 8; /* doesn't matter at this point */
xf86DrvMsg(pScreen->myNum, X_INFO,
"[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x 0x%04x/0x%04x]\n",
@ -904,6 +909,9 @@ static void RADEONSetAgpBase(RADEONInfoPtr info, ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
unsigned char *RADEONMMIO = info->MMIO;
if (info->ChipFamily >= CHIP_FAMILY_R600)
return;
/* drm already does this, so we can probably remove this.
* agp_base_2 ?
*/
@ -1177,13 +1185,14 @@ static int RADEONDRIKernelInit(RADEONInfoPtr info, ScreenPtr pScreen)
drm_radeon_init_t drmInfo;
memset(&drmInfo, 0, sizeof(drm_radeon_init_t));
if ( info->ChipFamily >= CHIP_FAMILY_R300 )
drmInfo.func = RADEON_INIT_R300_CP;
if ( info->ChipFamily >= CHIP_FAMILY_R600 )
drmInfo.func = RADEON_INIT_R600_CP;
else if ( info->ChipFamily >= CHIP_FAMILY_R300 )
drmInfo.func = RADEON_INIT_R300_CP;
else if ( info->ChipFamily >= CHIP_FAMILY_R200 )
drmInfo.func = RADEON_INIT_R200_CP;
else
if ( info->ChipFamily >= CHIP_FAMILY_R200 )
drmInfo.func = RADEON_INIT_R200_CP;
else
drmInfo.func = RADEON_INIT_CP;
drmInfo.func = RADEON_INIT_CP;
drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec);
drmInfo.is_pci = (info->cardType!=CARD_AGP);
@ -1217,7 +1226,8 @@ static int RADEONDRIKernelInit(RADEONInfoPtr info, ScreenPtr pScreen)
* registers back to their default values, so we need to restore
* those engine register here.
*/
RADEONEngineRestore(pScrn);
if (info->ChipFamily < CHIP_FAMILY_R600)
RADEONEngineRestore(pScrn);
return TRUE;
}
@ -1293,14 +1303,16 @@ static void RADEONDRIIrqInit(RADEONInfoPtr info, ScreenPtr pScreen)
"[drm] falling back to irq-free operation\n");
info->dri->irq = 0;
} else {
unsigned char *RADEONMMIO = info->MMIO;
info->ModeReg->gen_int_cntl = INREG( RADEON_GEN_INT_CNTL );
if (info->ChipFamily < CHIP_FAMILY_R600) {
unsigned char *RADEONMMIO = info->MMIO;
info->ModeReg->gen_int_cntl = INREG( RADEON_GEN_INT_CNTL );
/* Let the DRM know it can safely disable the vblank interrupts */
radeon_crtc_modeset_ioctl(XF86_CRTC_CONFIG_PTR(pScrn)->crtc[0],
FALSE);
radeon_crtc_modeset_ioctl(XF86_CRTC_CONFIG_PTR(pScrn)->crtc[0],
TRUE);
/* Let the DRM know it can safely disable the vblank interrupts */
radeon_crtc_modeset_ioctl(XF86_CRTC_CONFIG_PTR(pScrn)->crtc[0],
FALSE);
radeon_crtc_modeset_ioctl(XF86_CRTC_CONFIG_PTR(pScrn)->crtc[0],
TRUE);
}
}
}

View file

@ -674,8 +674,8 @@ static void radeon_write_mc_fb_agp_location(ScrnInfoPtr pScrn, int mask, uint32_
if (mask & LOC_FB)
OUTREG(R700_MC_VM_FB_LOCATION, fb_loc);
if (mask & LOC_AGP) {
OUTREG(R600_MC_VM_AGP_BOT, agp_loc);
OUTREG(R600_MC_VM_AGP_TOP, agp_loc_hi);
OUTREG(R700_MC_VM_AGP_BOT, agp_loc);
OUTREG(R700_MC_VM_AGP_TOP, agp_loc_hi);
}
} else if (info->ChipFamily >= CHIP_FAMILY_R600) {
if (mask & LOC_FB)
@ -724,8 +724,8 @@ static void radeon_read_mc_fb_agp_location(ScrnInfoPtr pScrn, int mask, uint32_t
if (mask & LOC_FB)
*fb_loc = INREG(R700_MC_VM_FB_LOCATION);
if (mask & LOC_AGP) {
*agp_loc = INREG(R600_MC_VM_AGP_BOT);
*agp_loc_hi = INREG(R600_MC_VM_AGP_TOP);
*agp_loc = INREG(R700_MC_VM_AGP_BOT);
*agp_loc_hi = INREG(R700_MC_VM_AGP_TOP);
}
} else if (info->ChipFamily >= CHIP_FAMILY_R600) {
if (mask & LOC_FB)
@ -1876,7 +1876,10 @@ static Bool RADEONPreInitChipType(ScrnInfoPtr pScrn)
/* treat PCIE IGP cards as PCI */
if (info->cardType == CARD_PCIE && info->IsIGP)
info->cardType = CARD_PCI;
info->cardType = CARD_PCI;
if ((info->ChipFamily >= CHIP_FAMILY_R600) && info->IsIGP)
info->cardType = CARD_PCIE;
if ((s = xf86GetOptValString(info->Options, OPTION_BUS_TYPE))) {
if (strcmp(s, "AGP") == 0) {
@ -1905,6 +1908,7 @@ static Bool RADEONPreInitChipType(ScrnInfoPtr pScrn)
info->Chipset != PCI_CHIP_RN50_5969);
#endif
#if 0
if (info->ChipFamily >= CHIP_FAMILY_R600) {
info->r600_shadow_fb = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@ -1912,6 +1916,7 @@ static Bool RADEONPreInitChipType(ScrnInfoPtr pScrn)
if (!xf86LoadSubModule(pScrn, "shadow"))
return FALSE;
}
#endif
return TRUE;
}
@ -1989,8 +1994,8 @@ static Bool RADEONPreInitAccel(ScrnInfoPtr pScrn)
if (info->ChipFamily >= CHIP_FAMILY_R600) {
xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
"No acceleration support available on R600 yet.\n");
return TRUE;
"Experimental R6xx/R7xx EXA support.\n");
info->useEXA = TRUE;
}
if (!xf86ReturnOptValBool(info->Options, OPTION_NOACCEL, FALSE)) {
@ -2336,7 +2341,10 @@ static Bool RADEONPreInitDRI(ScrnInfoPtr pScrn)
xf86DrvMsg(pScrn->scrnIndex, from, "Page Flipping %sabled%s\n",
info->dri->allowPageFlip ? "en" : "dis", reason);
info->DMAForXv = TRUE;
if (info->ChipFamily >= CHIP_FAMILY_R600)
info->DMAForXv = FALSE;
else
info->DMAForXv = TRUE;
from = xf86GetOptValBool(info->Options, OPTION_XV_DMA, &info->DMAForXv)
? X_CONFIG : X_INFO;
xf86DrvMsg(pScrn->scrnIndex, from,
@ -3638,11 +3646,9 @@ Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
RADEONDGAInit(pScreen);
/* Init Xv */
if (info->ChipFamily < CHIP_FAMILY_R600) {
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
"Initializing Xv\n");
RADEONInitVideo(pScreen);
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
"Initializing Xv\n");
RADEONInitVideo(pScreen);
if (info->r600_shadow_fb == TRUE) {
if (!shadowSetup(pScreen)) {
@ -3952,7 +3958,7 @@ static void RADEONAdjustMemMapRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save)
}
#ifdef USE_EXA
if (info->accelDFS)
if (info->accelDFS || (info->ChipFamily >= CHIP_FAMILY_R600))
{
drm_radeon_getparam_t gp;
int gart_base;

View file

@ -35,6 +35,7 @@
#include "radeon.h"
#include "radeon_reg.h"
#include "r600_reg.h"
#ifdef XF86DRI
#include "radeon_drm.h"
#endif

View file

@ -451,7 +451,7 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix,
#ifdef ONLY_ONCE
static PixmapPtr
PixmapPtr
RADEONGetDrawablePixmap(DrawablePtr pDrawable)
{
if (pDrawable->type == DRAWABLE_WINDOW)

View file

@ -65,15 +65,19 @@ void RADEONSetPitch (ScrnInfoPtr pScrn)
align_large = info->allowColorTiling || IS_AVIVO_VARIANT;
/* FIXME: May need to validate line pitch here */
switch (pScrn->depth / 8) {
case 1: pitch_mask = align_large ? 255 : 127;
break;
case 2: pitch_mask = align_large ? 127 : 31;
break;
case 3:
case 4: pitch_mask = align_large ? 63 : 15;
break;
}
if (info->ChipFamily < CHIP_FAMILY_R600) {
switch (pScrn->depth / 8) {
case 1: pitch_mask = align_large ? 255 : 127;
break;
case 2: pitch_mask = align_large ? 127 : 31;
break;
case 3:
case 4: pitch_mask = align_large ? 63 : 15;
break;
}
} else
pitch_mask = 255; /* r6xx/r7xx need 256B alignment for accel */
dummy = (pScrn->virtualX + pitch_mask) & ~pitch_mask;
pScrn->displayWidth = dummy;
info->CurrentLayout.displayWidth = pScrn->displayWidth;

View file

@ -3984,6 +3984,9 @@
#define R600_MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x2198
#define R700_MC_VM_FB_LOCATION 0x2024
#define R700_MC_VM_AGP_TOP 0x2028
#define R700_MC_VM_AGP_BOT 0x202c
#define R700_MC_VM_AGP_BASE 0x2030
#define R600_HDP_NONSURFACE_BASE 0x2c04
@ -5362,4 +5365,27 @@
#define R500_DYN_SCLK_PWMEM_PIPE 0x000d /* PLL */
/* r6xx/r7xx stuff */
#define R600_GRBM_SOFT_RESET 0x8020
# define R600_SOFT_RESET_CP (1 << 0)
#define R600_WAIT_UNTIL 0x8040
#define R600_CP_ME_CNTL 0x86d8
# define R600_CP_ME_HALT (1 << 28)
#define R600_CP_RB_BASE 0xc100
#define R600_CP_RB_CNTL 0xc104
# define R600_RB_NO_UPDATE (1 << 27)
# define R600_RB_RPTR_WR_ENA (1 << 31)
#define R600_CP_RB_RPTR_WR 0xc108
#define R600_CP_RB_RPTR_ADDR 0xc10c
#define R600_CP_RB_RPTR_ADDR_HI 0xc110
#define R600_CP_RB_WPTR 0xc114
#define R600_CP_RB_WPTR_ADDR 0xc118
#define R600_CP_RB_WPTR_ADDR_HI 0xc11c
#define R600_CP_RB_RPTR 0x8700
#define R600_CP_RB_WPTR_DELAY 0x8704
#endif

View file

@ -36,6 +36,7 @@
#include "radeon.h"
#include "radeon_reg.h"
#include "r600_reg.h"
#include "radeon_macros.h"
#include "radeon_probe.h"
#include "radeon_video.h"
@ -43,12 +44,18 @@
#include <X11/extensions/Xv.h>
#include "fourcc.h"
extern void
R600DisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv);
#define IMAGE_MAX_WIDTH 2048
#define IMAGE_MAX_HEIGHT 2048
#define IMAGE_MAX_WIDTH_R500 4096
#define IMAGE_MAX_HEIGHT_R500 4096
#define IMAGE_MAX_WIDTH_R600 8192
#define IMAGE_MAX_HEIGHT_R600 8192
static Bool
RADEONTilingEnabled(ScrnInfoPtr pScrn, PixmapPtr pPix)
{
@ -146,6 +153,82 @@ static __inline__ uint32_t F_TO_24(float val)
#endif /* XF86DRI */
static void
CopyPlanartoNV12(unsigned char *y_src, unsigned char *u_src, unsigned char *v_src,
unsigned char *dst,
int srcPitch, int srcPitch2, int dstPitch,
int w, int h)
{
int i, j;
/* Y */
if (srcPitch == dstPitch) {
memcpy(dst, y_src, srcPitch * h);
dst += (dstPitch * h);
} else {
for (i = 0; i < h; i++) {
memcpy(dst, y_src, srcPitch);
y_src += srcPitch;
dst += dstPitch;
}
}
/* tex base need 256B alignment */
if (h & 1)
dst += dstPitch;
/* UV */
for (i = 0; i < (h >> 1); i++) {
unsigned char *u = u_src;
unsigned char *v = v_src;
unsigned char *uv = dst;
for (j = 0; j < w; j++) {
uv[0] = v[j];
uv[1] = u[j];
uv += 2;
}
dst += dstPitch;
u_src += srcPitch2;
v_src += srcPitch2;
}
}
static void
CopyPackedtoNV12(unsigned char *src, unsigned char *dst,
int srcPitch, int dstPitch,
int w, int h, int id)
{
int i, j;
int uv_offset = dstPitch * h;
uv_offset = (uv_offset + 255) & ~255;
// FOURCC_UYVY: U0 Y0 V0 Y1
// FOURCC_YUY2: Y0 U0 Y1 V0
for (i = 0; i < h; i++) {
unsigned char *y = dst;
unsigned char *uv = (unsigned char *)dst + uv_offset;
for (j = 0; j < (w / 2); j++) {
if (id == FOURCC_UYVY) {
uv[1] = src[(j * 4) + 0];
y[0] = src[(j * 4) + 1];
uv[0] = src[(j * 4) + 2];
y[1] = src[(j * 4) + 3];
} else {
y[0] = src[(j * 4) + 0];
uv[1] = src[(j * 4) + 1];
y[1] = src[(j * 4) + 2];
uv[0] = src[(j * 4) + 3];
}
y += 2;
uv += 2;
}
dst += dstPitch;
src += srcPitch;
}
}
static int
RADEONPutImageTextured(ScrnInfoPtr pScrn,
short src_x, short src_y,
@ -214,7 +297,10 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
break;
}
dstPitch = (dstPitch + 63) & ~63;
if (info->ChipFamily >= CHIP_FAMILY_R600)
dstPitch = (dstPitch + 511) & ~511;
else
dstPitch = (dstPitch + 63) & ~63;
if (pPriv->video_memory != NULL && size != pPriv->size) {
radeon_legacy_free_memory(pScrn, pPriv->video_memory);
@ -222,16 +308,21 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
}
if (pPriv->video_memory == NULL) {
pPriv->video_offset = radeon_legacy_allocate_memory(pScrn,
&pPriv->video_memory,
size * 2, 64);
if (info->ChipFamily >= CHIP_FAMILY_R600)
pPriv->video_offset = radeon_legacy_allocate_memory(pScrn,
&pPriv->video_memory,
size * 2, 512);
else
pPriv->video_offset = radeon_legacy_allocate_memory(pScrn,
&pPriv->video_memory,
size * 2, 64);
if (pPriv->video_offset == 0)
return BadAlloc;
}
/* Bicubic filter setup */
pPriv->bicubic_enabled = (pPriv->bicubic_state != BICUBIC_OFF);
if (!(IS_R300_3D || IS_R500_3D))
if (!(IS_R300_3D || IS_R500_3D || IS_R600_3D))
pPriv->bicubic_enabled = FALSE;
if (pPriv->bicubic_enabled && (pPriv->bicubic_state == BICUBIC_AUTO)) {
/*
@ -280,7 +371,10 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
pPriv->src_offset = pPriv->video_offset + info->fbLocation + pScrn->fbOffset;
pPriv->src_addr = (uint8_t *)(info->FB + pPriv->video_offset + (top * dstPitch));
if (info->ChipFamily >= CHIP_FAMILY_R600)
pPriv->src_addr = (uint8_t *)(info->FB + pPriv->video_offset);
else
pPriv->src_addr = (uint8_t *)(info->FB + pPriv->video_offset + (top * dstPitch));
pPriv->src_pitch = dstPitch;
pPriv->size = size;
pPriv->pDraw = pDraw;
@ -294,29 +388,51 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
top &= ~1;
nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
s2offset = srcPitch * height;
s3offset = (srcPitch2 * (height >> 1)) + s2offset;
top &= ~1;
pPriv->src_addr += left << 1;
tmp = ((top >> 1) * srcPitch2) + (left >> 1);
s2offset += tmp;
s3offset += tmp;
if (id == FOURCC_I420) {
tmp = s2offset;
s2offset = s3offset;
s3offset = tmp;
if (info->ChipFamily >= CHIP_FAMILY_R600) {
s2offset = srcPitch * height;
s3offset = (srcPitch2 * (height >> 1)) + s2offset;
if (id == FOURCC_YV12)
CopyPlanartoNV12(buf, buf + s3offset, buf + s2offset,
pPriv->src_addr,
srcPitch, srcPitch2, pPriv->src_pitch,
width, height);
else
CopyPlanartoNV12(buf, buf + s2offset, buf + s3offset,
pPriv->src_addr,
srcPitch, srcPitch2, pPriv->src_pitch,
width, height);
} else {
top &= ~1;
nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
s2offset = srcPitch * height;
s3offset = (srcPitch2 * (height >> 1)) + s2offset;
top &= ~1;
pPriv->src_addr += left << 1;
tmp = ((top >> 1) * srcPitch2) + (left >> 1);
s2offset += tmp;
s3offset += tmp;
if (id == FOURCC_I420) {
tmp = s2offset;
s2offset = s3offset;
s3offset = tmp;
}
RADEONCopyMungedData(pScrn, buf + (top * srcPitch) + left,
buf + s2offset, buf + s3offset, pPriv->src_addr,
srcPitch, srcPitch2, dstPitch, nlines, npixels);
}
RADEONCopyMungedData(pScrn, buf + (top * srcPitch) + left,
buf + s2offset, buf + s3offset, pPriv->src_addr,
srcPitch, srcPitch2, dstPitch, nlines, npixels);
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
nlines = ((y2 + 0xffff) >> 16) - top;
RADEONCopyData(pScrn, buf, pPriv->src_addr, srcPitch, dstPitch, nlines, npixels, 2);
if (info->ChipFamily >= CHIP_FAMILY_R600) {
CopyPackedtoNV12(buf, pPriv->src_addr,
2 * width, pPriv->src_pitch,
width, height, id);
} else {
nlines = ((y2 + 0xffff) >> 16) - top;
RADEONCopyData(pScrn, buf, pPriv->src_addr, srcPitch, dstPitch, nlines, npixels, 2);
}
break;
}
@ -340,7 +456,9 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
pPriv->h = height;
#ifdef XF86DRI
if (info->directRenderingEnabled)
if (IS_R600_3D)
R600DisplayTexturedVideo(pScrn, pPriv);
else if (info->directRenderingEnabled)
RADEONDisplayTexturedVideoCP(pScrn, pPriv);
else
#endif
@ -370,6 +488,16 @@ static XF86VideoEncodingRec DummyEncodingR500[1] =
}
};
static XF86VideoEncodingRec DummyEncodingR600[1] =
{
{
0,
"XV_IMAGE",
IMAGE_MAX_WIDTH_R600, IMAGE_MAX_HEIGHT_R600,
{1, 1}
}
};
#define NUM_FORMATS 3
static XF86VideoFormatRec Formats[NUM_FORMATS] =
@ -471,7 +599,9 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen)
adapt->flags = 0;
adapt->name = "Radeon Textured Video";
adapt->nEncodings = 1;
if (IS_R500_3D)
if (IS_R600_3D)
adapt->pEncodings = DummyEncodingR600;
else if (IS_R500_3D)
adapt->pEncodings = DummyEncodingR500;
else
adapt->pEncodings = DummyEncoding;
@ -483,7 +613,7 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen)
pPortPriv =
(RADEONPortPrivPtr)(&adapt->pPortPrivates[num_texture_ports]);
if (IS_R300_3D || IS_R500_3D) {
if (IS_R300_3D || IS_R500_3D || IS_R600_3D) {
adapt->pAttributes = Attributes_r300;
adapt->nAttributes = NUM_ATTRIBUTES_R300;
} else {