Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4358 Serge 1
/*
2
 * Copyright (C) 2008 Nicolai Haehnle.
3
 *
4
 * All Rights Reserved.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining
7
 * a copy of this software and associated documentation files (the
8
 * "Software"), to deal in the Software without restriction, including
9
 * without limitation the rights to use, copy, modify, merge, publish,
10
 * distribute, sublicense, and/or sell copies of the Software, and to
11
 * permit persons to whom the Software is furnished to do so, subject to
12
 * the following conditions:
13
 *
14
 * The above copyright notice and this permission notice (including the
15
 * next paragraph) shall be included in all copies or substantial
16
 * portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 *
26
 */
27
 
28
#ifndef __RADEON_PROGRAM_PAIR_H_
29
#define __RADEON_PROGRAM_PAIR_H_
30
 
31
#include "radeon_code.h"
32
#include "radeon_opcodes.h"
33
#include "radeon_program_constants.h"
34
 
35
struct radeon_compiler;
36
 
37
 
38
/**
39
 * \file
40
 * Represents a paired ALU instruction, as found in R300 and R500
41
 * fragment programs.
42
 *
43
 * Note that this representation is taking some liberties as far
44
 * as register files are concerned, to allow separate register
45
 * allocation.
46
 *
47
 * Also note that there are some subtleties in that the semantics
48
 * of certain opcodes are implicitly changed in this representation;
49
 * see \ref rc_pair_translate
50
 */
51
 
52
/* For rgb and alpha instructions when arg[n].Source = RC_PAIR_PRESUB_SRC, then
53
 * the presubtract value will be used, and
54
 * {RGB,Alpha}.Src[RC_PAIR_PRESUB_SRC].File will be set to RC_FILE_PRESUB.
55
 */
56
#define RC_PAIR_PRESUB_SRC 3
57
 
58
struct rc_pair_instruction_source {
59
	unsigned int Used:1;
60
	unsigned int File:4;
61
	unsigned int Index:RC_REGISTER_INDEX_BITS;
62
};
63
 
64
struct rc_pair_instruction_arg {
65
	unsigned int Source:2;
66
	unsigned int Swizzle:12;
67
	unsigned int Abs:1;
68
	unsigned int Negate:1;
69
};
70
 
71
struct rc_pair_sub_instruction {
72
	unsigned int Opcode:8;
73
	unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
74
	unsigned int WriteMask:4;
75
	unsigned int Target:2;
76
	unsigned int OutputWriteMask:3;
77
	unsigned int DepthWriteMask:1;
78
	unsigned int Saturate:1;
79
	unsigned int Omod:3;
80
 
81
	struct rc_pair_instruction_source Src[4];
82
	struct rc_pair_instruction_arg Arg[3];
83
};
84
 
85
struct rc_pair_instruction {
86
	struct rc_pair_sub_instruction RGB;
87
	struct rc_pair_sub_instruction Alpha;
88
 
89
	unsigned int WriteALUResult:2;
90
	unsigned int ALUResultCompare:3;
91
	unsigned int Nop:1;
92
	unsigned int SemWait:1;
93
};
94
 
95
typedef void (*rc_pair_foreach_src_fn)
96
			(void *, struct rc_pair_instruction_source *);
97
 
98
/**
99
 * General helper functions for dealing with the paired instruction format.
100
 */
101
/*@{*/
102
int rc_pair_alloc_source(struct rc_pair_instruction *pair,
103
	unsigned int rgb, unsigned int alpha,
104
	rc_register_file file, unsigned int index);
105
 
106
void rc_pair_foreach_source_that_alpha_reads(
107
	struct rc_pair_instruction * pair,
108
	void * data,
109
	rc_pair_foreach_src_fn cb);
110
 
111
void rc_pair_foreach_source_that_rgb_reads(
112
	struct rc_pair_instruction * pair,
113
	void * data,
114
	rc_pair_foreach_src_fn cb);
115
 
116
struct rc_pair_instruction_source * rc_pair_get_src(
117
	struct rc_pair_instruction * pair_inst,
118
	struct rc_pair_instruction_arg * arg);
119
 
120
int rc_pair_get_src_index(
121
	struct rc_pair_instruction * pair_inst,
122
	struct rc_pair_instruction_source * src);
123
/*@}*/
124
 
125
 
126
/**
127
 * Compiler passes that operate with the paired format.
128
 */
129
/*@{*/
130
struct radeon_pair_handler;
131
 
132
void rc_pair_translate(struct radeon_compiler *cc, void *user);
133
void rc_pair_schedule(struct radeon_compiler *cc, void *user);
134
void rc_pair_regalloc(struct radeon_compiler *cc, void *user);
135
void rc_pair_regalloc_inputs_only(struct radeon_compiler *cc, void *user);
136
void rc_pair_remove_dead_sources(struct radeon_compiler *c, void *user);
137
/*@}*/
138
 
139
#endif /* __RADEON_PROGRAM_PAIR_H_ */