• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #pragma once
35 #ifndef LOWER_BUFFER_ACCESS_H
36 #define LOWER_BUFFER_ACCESS_H
37 
38 #include "ir.h"
39 #include "ir_rvalue_visitor.h"
40 
41 namespace lower_buffer_access {
42 
43 class lower_buffer_access : public ir_rvalue_enter_visitor {
44 public:
45    virtual void
46    insert_buffer_access(void *mem_ctx, ir_dereference *deref,
47                         const glsl_type *type, ir_rvalue *offset,
48                         unsigned mask, int channel) = 0;
49 
50    void emit_access(void *mem_ctx, bool is_write, ir_dereference *deref,
51                     ir_variable *base_offset, unsigned int deref_offset,
52                     bool row_major, int matrix_columns,
53                     unsigned int packing, 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, int *matrix_columns,
60                             const glsl_struct_field **struct_field,
61                             enum glsl_interface_packing packing);
62 };
63 
64 } /* namespace lower_buffer_access */
65 
66 #endif /* LOWER_BUFFER_ACCESS_H */
67