| 1 |
/* |
| 2 |
* Copyright (c) 2015 Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice (including the next |
| 12 |
* paragraph) shall be included in all copies or substantial portions of the |
| 13 |
* Software. |
| 14 |
* |
| 15 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 |
* DEALINGS IN THE SOFTWARE. |
| 22 |
*/ |
| 23 |
|
| 24 |
/** |
| 25 |
* \file lower_buffer_access.h |
| 26 |
* |
| 27 |
* Helper for IR lowering pass to replace dereferences of buffer object based |
| 28 |
* shader variables with intrinsic function calls. |
| 29 |
* |
| 30 |
* This helper is used by lowering passes for UBOs, SSBOs and compute shader |
| 31 |
* shared variables. |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifndef LOWER_BUFFER_ACCESS_H |
| 35 |
#define LOWER_BUFFER_ACCESS_H |
| 36 |
|
| 37 |
#include "ir.h" |
| 38 |
#include "ir_rvalue_visitor.h" |
| 39 |
|
| 40 |
namespace lower_buffer_access { |
| 41 |
|
| 42 |
class lower_buffer_access : public ir_rvalue_enter_visitor { |
| 43 |
public: |
| 44 |
virtual void |
| 45 |
insert_buffer_access(void *mem_ctx, ir_dereference *deref, |
| 46 |
const glsl_type *type, ir_rvalue *offset, |
| 47 |
unsigned mask, int channel) = 0; |
| 48 |
|
| 49 |
void emit_access(void *mem_ctx, bool is_write, ir_dereference *deref, |
| 50 |
ir_variable *base_offset, unsigned int deref_offset, |
| 51 |
bool row_major, const glsl_type *matrix_type, |
| 52 |
enum glsl_interface_packing packing, |
| 53 |
unsigned int write_mask); |
| 54 |
|
| 55 |
bool is_dereferenced_thing_row_major(const ir_rvalue *deref); |
| 56 |
|
| 57 |
void setup_buffer_access(void *mem_ctx, ir_rvalue *deref, |
| 58 |
ir_rvalue **offset, unsigned *const_offset, |
| 59 |
bool *row_major, |
| 60 |
const glsl_type **matrix_type, |
| 61 |
const glsl_struct_field **struct_field, |
| 62 |
enum glsl_interface_packing packing); |
| 63 |
|
| 64 |
protected: |
| 65 |
bool use_std430_as_default; |
| 66 |
}; |
| 67 |
|
| 68 |
} /* namespace lower_buffer_access */ |
| 69 |
|
| 70 |
#endif /* LOWER_BUFFER_ACCESS_H */ |