Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: media-libs/mesa/files/7.9-glsl-vector-compare.patch

Issue 5925002: Switch to Mesa 7.9. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/chromiumos-overlay.git@master
Patch Set: Switch to Mesa 7.9 version 2. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 From e16c9d5d03a4606b37cbeb84358925913086d6eb Mon Sep 17 00:00:00 2001
2 From: Kenneth Graunke <kenneth@whitecape.org>
3 Date: Wed, 17 Nov 2010 18:40:28 +0000
4 Subject: glsl: Fix constant expression handling for <, >, <=, >= on vectors.
5
6 ir_binop_less, ir_binop_greater, ir_binop_lequal, and ir_binop_gequal
7 are defined to work on vectors as well as scalars, as long as the two
8 operands have the same type.
9
10 This is evident from both ir_validate.cpp and our use of these opcodes
11 in the GLSL lessThan, greaterThan, lessThanEqual, greaterThanEqual
12 built-in functions.
13
14 Found by code inspection. Not known to fix any bugs. Presumably, our
15 tests for the built-in comparison functions must pass because C.E.
16 handling is done on the ir_call of "greaterThan" rather than the inlined
17 opcode. The C.E. handling of the built-in function calls is correct.
18
19 NOTE: This is a candidate for the 7.9 branch.
20 ---
21 diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expressi on.cpp
22 index a6713e5..7402468 100644
23 --- a/src/glsl/ir_constant_expression.cpp
24 +++ b/src/glsl/ir_constant_expression.cpp
25 @@ -581,63 +581,75 @@ ir_expression::constant_expression_value()
26 break;
27
28 case ir_binop_less:
29 - switch (op[0]->type->base_type) {
30 - case GLSL_TYPE_UINT:
31 - data.b[0] = op[0]->value.u[0] < op[1]->value.u[0];
32 - break;
33 - case GLSL_TYPE_INT:
34 - data.b[0] = op[0]->value.i[0] < op[1]->value.i[0];
35 - break;
36 - case GLSL_TYPE_FLOAT:
37 - data.b[0] = op[0]->value.f[0] < op[1]->value.f[0];
38 - break;
39 - default:
40 - assert(0);
41 + assert(op[0]->type == op[1]->type);
42 + for (unsigned c = 0; c < op[0]->type->components(); c++) {
43 + switch (op[0]->type->base_type) {
44 + case GLSL_TYPE_UINT:
45 + data.b[0] = op[0]->value.u[0] < op[1]->value.u[0];
46 + break;
47 + case GLSL_TYPE_INT:
48 + data.b[0] = op[0]->value.i[0] < op[1]->value.i[0];
49 + break;
50 + case GLSL_TYPE_FLOAT:
51 + data.b[0] = op[0]->value.f[0] < op[1]->value.f[0];
52 + break;
53 + default:
54 + assert(0);
55 + }
56 }
57 break;
58 case ir_binop_greater:
59 - switch (op[0]->type->base_type) {
60 - case GLSL_TYPE_UINT:
61 - data.b[0] = op[0]->value.u[0] > op[1]->value.u[0];
62 - break;
63 - case GLSL_TYPE_INT:
64 - data.b[0] = op[0]->value.i[0] > op[1]->value.i[0];
65 - break;
66 - case GLSL_TYPE_FLOAT:
67 - data.b[0] = op[0]->value.f[0] > op[1]->value.f[0];
68 - break;
69 - default:
70 - assert(0);
71 + assert(op[0]->type == op[1]->type);
72 + for (unsigned c = 0; c < op[0]->type->components(); c++) {
73 + switch (op[0]->type->base_type) {
74 + case GLSL_TYPE_UINT:
75 + data.b[c] = op[0]->value.u[c] > op[1]->value.u[c];
76 + break;
77 + case GLSL_TYPE_INT:
78 + data.b[c] = op[0]->value.i[c] > op[1]->value.i[c];
79 + break;
80 + case GLSL_TYPE_FLOAT:
81 + data.b[c] = op[0]->value.f[c] > op[1]->value.f[c];
82 + break;
83 + default:
84 + assert(0);
85 + }
86 }
87 break;
88 case ir_binop_lequal:
89 - switch (op[0]->type->base_type) {
90 - case GLSL_TYPE_UINT:
91 - data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0];
92 - break;
93 - case GLSL_TYPE_INT:
94 - data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0];
95 - break;
96 - case GLSL_TYPE_FLOAT:
97 - data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0];
98 - break;
99 - default:
100 - assert(0);
101 + assert(op[0]->type == op[1]->type);
102 + for (unsigned c = 0; c < op[0]->type->components(); c++) {
103 + switch (op[0]->type->base_type) {
104 + case GLSL_TYPE_UINT:
105 + data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0];
106 + break;
107 + case GLSL_TYPE_INT:
108 + data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0];
109 + break;
110 + case GLSL_TYPE_FLOAT:
111 + data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0];
112 + break;
113 + default:
114 + assert(0);
115 + }
116 }
117 break;
118 case ir_binop_gequal:
119 - switch (op[0]->type->base_type) {
120 - case GLSL_TYPE_UINT:
121 - data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0];
122 - break;
123 - case GLSL_TYPE_INT:
124 - data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0];
125 - break;
126 - case GLSL_TYPE_FLOAT:
127 - data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0];
128 - break;
129 - default:
130 - assert(0);
131 + assert(op[0]->type == op[1]->type);
132 + for (unsigned c = 0; c < op[0]->type->components(); c++) {
133 + switch (op[0]->type->base_type) {
134 + case GLSL_TYPE_UINT:
135 + data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0];
136 + break;
137 + case GLSL_TYPE_INT:
138 + data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0];
139 + break;
140 + case GLSL_TYPE_FLOAT:
141 + data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0];
142 + break;
143 + default:
144 + assert(0);
145 + }
146 }
147 break;
148 case ir_binop_equal:
149 --
150 cgit v0.8.3-6-g21f6
OLDNEW
« no previous file with comments | « media-libs/mesa/files/7.9-glisbuffer.patch ('k') | media-libs/mesa/files/7.9-optimize-discards.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698