profiles/mojoshader_profile.h
author Caleb Cornett <caleb.cornett@outlook.com>
Thu, 05 Dec 2019 12:11:01 -0500
changeset 1221 012dec2787aa
parent 1212 124155bb9bed
child 1224 21cd84f1aa0a
permissions -rw-r--r--
Replicate D3D's div by 0 behavior for RCP/RSQ (GLSL Edition)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1199
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     1
/**
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     2
 * MojoShader; generate shader programs from bytecode of compiled
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     3
 *  Direct3D shaders.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     4
 *
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     6
 *
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     7
 *  This file written by Ryan C. Gordon.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     8
 */
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
     9
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    10
#ifndef MOJOSHADER_PROFILE_H
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    11
#define MOJOSHADER_PROFILE_H
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    12
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    13
#include "../mojoshader_internal.h"
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    14
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    15
typedef struct ConstantsList
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    16
{
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    17
    MOJOSHADER_constant constant;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    18
    struct ConstantsList *next;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    19
} ConstantsList;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    20
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    21
typedef struct VariableList
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    22
{
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    23
    MOJOSHADER_uniformType type;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    24
    int index;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    25
    int count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    26
    ConstantsList *constant;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    27
    int used;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    28
    int emit_position;  // used in some profiles.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    29
    struct VariableList *next;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    30
} VariableList;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    31
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    32
typedef struct RegisterList
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    33
{
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    34
    RegisterType regtype;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    35
    int regnum;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    36
    MOJOSHADER_usage usage;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    37
    unsigned int index;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    38
    int writemask;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    39
    int misc;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    40
    int written;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    41
    const VariableList *array;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    42
    struct RegisterList *next;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    43
} RegisterList;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    44
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    45
typedef struct
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    46
{
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    47
    const uint32 *token;   // this is the unmolested token in the stream.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    48
    int regnum;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    49
    int swizzle;  // xyzw (all four, not split out).
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    50
    int swizzle_x;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    51
    int swizzle_y;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    52
    int swizzle_z;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    53
    int swizzle_w;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    54
    SourceMod src_mod;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    55
    RegisterType regtype;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    56
    int relative;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    57
    RegisterType relative_regtype;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    58
    int relative_regnum;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    59
    int relative_component;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    60
    const VariableList *relative_array;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    61
} SourceArgInfo;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    62
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    63
struct Profile;  // predeclare.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    64
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    65
typedef struct CtabData
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    66
{
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    67
    int have_ctab;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    68
    int symbol_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    69
    MOJOSHADER_symbol *symbols;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    70
} CtabData;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    71
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    72
// Context...this is state that changes as we parse through a shader...
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    73
typedef struct Context
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    74
{
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    75
    int isfail;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    76
    int out_of_memory;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    77
    MOJOSHADER_malloc malloc;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    78
    MOJOSHADER_free free;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    79
    void *malloc_data;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    80
    int current_position;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    81
    const uint32 *orig_tokens;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    82
    const uint32 *tokens;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    83
    uint32 tokencount;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    84
    int know_shader_size;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    85
    const MOJOSHADER_swizzle *swizzles;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    86
    unsigned int swizzles_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    87
    const MOJOSHADER_samplerMap *samplermap;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    88
    unsigned int samplermap_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    89
    Buffer *output;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    90
    Buffer *preflight;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    91
    Buffer *globals;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    92
    Buffer *inputs;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    93
    Buffer *outputs;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    94
    Buffer *helpers;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    95
    Buffer *subroutines;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    96
    Buffer *mainline_intro;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    97
    Buffer *mainline_arguments;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    98
    Buffer *mainline_top;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
    99
    Buffer *mainline;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   100
    Buffer *postflight;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   101
    Buffer *ignore;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   102
    Buffer *output_stack[3];
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   103
    int indent_stack[3];
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   104
    int output_stack_len;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   105
    int indent;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   106
    const char *shader_type_str;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   107
    const char *endline;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   108
    const char *mainfn;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   109
    int endline_len;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   110
    int profileid;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   111
    const struct Profile *profile;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   112
    MOJOSHADER_shaderType shader_type;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   113
    uint8 major_ver;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   114
    uint8 minor_ver;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   115
    DestArgInfo dest_arg;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   116
    SourceArgInfo source_args[5];
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   117
    SourceArgInfo predicate_arg;  // for predicated instructions.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   118
    uint32 dwords[4];
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   119
    uint32 version_token;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   120
    int instruction_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   121
    uint32 instruction_controls;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   122
    uint32 previous_opcode;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   123
    int coissue;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   124
    int loops;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   125
    int reps;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   126
    int max_reps;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   127
    int cmps;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   128
    int scratch_registers;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   129
    int max_scratch_registers;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   130
    int branch_labels_stack_index;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   131
    int branch_labels_stack[32];
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   132
    int assigned_branch_labels;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   133
    int assigned_vertex_attributes;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   134
    int last_address_reg_component;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   135
    RegisterList used_registers;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   136
    RegisterList defined_registers;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   137
    ErrorList *errors;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   138
    int constant_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   139
    ConstantsList *constants;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   140
    int uniform_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   141
    int uniform_float4_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   142
    int uniform_int4_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   143
    int uniform_bool_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   144
    RegisterList uniforms;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   145
    int attribute_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   146
    RegisterList attributes;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   147
    int sampler_count;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   148
    RegisterList samplers;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   149
    VariableList *variables;  // variables to register mapping.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   150
    int centroid_allowed;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   151
    CtabData ctab;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   152
    int have_relative_input_registers;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   153
    int have_multi_color_outputs;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   154
    int determined_constants_arrays;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   155
    int predicated;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   156
    int uses_pointsize;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   157
    int uses_fog;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   158
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   159
    // !!! FIXME: move these into SUPPORT_PROFILE sections.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   160
    int glsl_generated_lit_helper;
1212
124155bb9bed GLSL: Implement texldl instruction
Katelyn Gadd <kg@luminance.org>
parents: 1199
diff changeset
   161
    int glsl_generated_texlod_setup;
1199
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   162
    int glsl_generated_texm3x3spec_helper;
1221
012dec2787aa Replicate D3D's div by 0 behavior for RCP/RSQ (GLSL Edition)
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1212
diff changeset
   163
    int glsl_need_max_float;
1199
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   164
    int arb1_wrote_position;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   165
    // !!! FIXME: move these into SUPPORT_PROFILE sections.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   166
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   167
    int have_preshader;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   168
    int ignores_ctab;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   169
    int reset_texmpad;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   170
    int texm3x2pad_dst0;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   171
    int texm3x2pad_src0;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   172
    int texm3x3pad_dst0;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   173
    int texm3x3pad_src0;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   174
    int texm3x3pad_dst1;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   175
    int texm3x3pad_src1;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   176
    MOJOSHADER_preshader *preshader;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   177
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   178
#if SUPPORT_PROFILE_ARB1_NV
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   179
    int profile_supports_nv2;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   180
    int profile_supports_nv3;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   181
    int profile_supports_nv4;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   182
#endif
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   183
#if SUPPORT_PROFILE_GLSL120
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   184
    int profile_supports_glsl120;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   185
#endif
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   186
#if SUPPORT_PROFILE_GLSLES
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   187
    int profile_supports_glsles;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   188
#endif
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   189
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   190
#if SUPPORT_PROFILE_METAL
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   191
    int metal_need_header_common;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   192
    int metal_need_header_math;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   193
    int metal_need_header_relational;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   194
    int metal_need_header_geometric;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   195
    int metal_need_header_graphics;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   196
    int metal_need_header_texture;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   197
#endif
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   198
} Context;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   199
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   200
// Use these macros so we can remove all bits of these profiles from the build.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   201
#if SUPPORT_PROFILE_ARB1_NV
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   202
#define support_nv2(ctx) ((ctx)->profile_supports_nv2)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   203
#define support_nv3(ctx) ((ctx)->profile_supports_nv3)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   204
#define support_nv4(ctx) ((ctx)->profile_supports_nv4)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   205
#else
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   206
#define support_nv2(ctx) (0)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   207
#define support_nv3(ctx) (0)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   208
#define support_nv4(ctx) (0)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   209
#endif
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   210
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   211
#if SUPPORT_PROFILE_GLSL120
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   212
#define support_glsl120(ctx) ((ctx)->profile_supports_glsl120)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   213
#else
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   214
#define support_glsl120(ctx) (0)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   215
#endif
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   216
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   217
#if SUPPORT_PROFILE_GLSLES
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   218
#define support_glsles(ctx) ((ctx)->profile_supports_glsles)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   219
#else
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   220
#define support_glsles(ctx) (0)
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   221
#endif
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   222
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   223
// Profile entry points...
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   224
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   225
// one emit function for each opcode in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   226
typedef void (*emit_function)(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   227
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   228
// one emit function for starting output in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   229
typedef void (*emit_start)(Context *ctx, const char *profilestr);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   230
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   231
// one emit function for ending output in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   232
typedef void (*emit_end)(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   233
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   234
// one emit function for phase opcode output in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   235
typedef void (*emit_phase)(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   236
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   237
// one emit function for finalizing output in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   238
typedef void (*emit_finalize)(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   239
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   240
// one emit function for global definitions in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   241
typedef void (*emit_global)(Context *ctx, RegisterType regtype, int regnum);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   242
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   243
// one emit function for relative uniform arrays in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   244
typedef void (*emit_array)(Context *ctx, VariableList *var);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   245
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   246
// one emit function for relative constants arrays in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   247
typedef void (*emit_const_array)(Context *ctx,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   248
                                 const struct ConstantsList *constslist,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   249
                                 int base, int size);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   250
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   251
// one emit function for uniforms in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   252
typedef void (*emit_uniform)(Context *ctx, RegisterType regtype, int regnum,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   253
                             const VariableList *var);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   254
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   255
// one emit function for samplers in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   256
typedef void (*emit_sampler)(Context *ctx, int stage, TextureType ttype,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   257
                             int texbem);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   258
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   259
// one emit function for attributes in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   260
typedef void (*emit_attribute)(Context *ctx, RegisterType regtype, int regnum,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   261
                               MOJOSHADER_usage usage, int index, int wmask,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   262
                               int flags);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   263
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   264
// one args function for each possible sequence of opcode arguments.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   265
typedef int (*args_function)(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   266
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   267
// one state function for each opcode where we have state machine updates.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   268
typedef void (*state_function)(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   269
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   270
// one function for varnames in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   271
typedef const char *(*varname_function)(Context *c, RegisterType t, int num);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   272
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   273
// one function for const var array in each profile.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   274
typedef const char *(*const_array_varname_function)(Context *c, int base, int size);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   275
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   276
typedef struct Profile
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   277
{
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   278
    const char *name;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   279
    emit_start start_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   280
    emit_end end_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   281
    emit_phase phase_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   282
    emit_global global_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   283
    emit_array array_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   284
    emit_const_array const_array_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   285
    emit_uniform uniform_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   286
    emit_sampler sampler_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   287
    emit_attribute attribute_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   288
    emit_finalize finalize_emitter;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   289
    varname_function get_varname;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   290
    const_array_varname_function get_const_array_varname;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   291
} Profile;
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   292
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   293
// Common utilities...
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   294
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   295
void out_of_memory(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   296
void *Malloc(Context *ctx, const size_t len);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   297
char *StrDup(Context *ctx, const char *str);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   298
void Free(Context *ctx, void *ptr);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   299
void * MOJOSHADERCALL MallocBridge(int bytes, void *data);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   300
void MOJOSHADERCALL FreeBridge(void *ptr, void *data);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   301
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   302
int set_output(Context *ctx, Buffer **section);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   303
void push_output(Context *ctx, Buffer **section);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   304
void pop_output(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   305
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   306
uint32 ver_ui32(const uint8 major, const uint8 minor);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   307
int shader_version_supported(const uint8 maj, const uint8 min);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   308
int shader_version_atleast(const Context *ctx, const uint8 maj,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   309
                           const uint8 min);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   310
int shader_version_exactly(const Context *ctx, const uint8 maj,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   311
                           const uint8 min);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   312
int shader_is_pixel(const Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   313
int shader_is_vertex(const Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   314
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   315
int isfail(const Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   316
void failf(Context *ctx, const char *fmt, ...);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   317
void fail(Context *ctx, const char *reason);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   318
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   319
void output_line(Context *ctx, const char *fmt, ...);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   320
void output_blank_line(Context *ctx);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   321
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   322
void floatstr(Context *ctx, char *buf, size_t bufsize, float f,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   323
              int leavedecimal);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   324
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   325
RegisterList *reglist_insert(Context *ctx, RegisterList *prev,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   326
                             const RegisterType regtype,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   327
                             const int regnum);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   328
RegisterList *reglist_find(const RegisterList *prev,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   329
                           const RegisterType rtype,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   330
                           const int regnum);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   331
RegisterList *set_used_register(Context *ctx,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   332
                                const RegisterType regtype,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   333
                                const int regnum,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   334
                                const int written);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   335
void set_defined_register(Context *ctx, const RegisterType rtype,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   336
                          const int regnum);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   337
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   338
int writemask_xyzw(const int writemask);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   339
int writemask_xyz(const int writemask);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   340
int writemask_xy(const int writemask);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   341
int writemask_x(const int writemask);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   342
int writemask_y(const int writemask);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   343
int replicate_swizzle(const int swizzle);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   344
int no_swizzle(const int swizzle);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   345
int vecsize_from_writemask(const int m);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   346
void set_dstarg_writemask(DestArgInfo *dst, const int mask);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   347
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   348
int isscalar(Context *ctx, const MOJOSHADER_shaderType shader_type,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   349
             const RegisterType rtype, const int rnum);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   350
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   351
static const char swizzle_channels[] = { 'x', 'y', 'z', 'w' };
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   352
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   353
const char *get_D3D_register_string(Context *ctx,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   354
                                    RegisterType regtype,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   355
                                    int regnum, char *regnum_str,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   356
                                    size_t regnum_size);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   357
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   358
// !!! FIXME: These should stay in the mojoshader_profile_d3d file
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   359
// !!! FIXME: but ARB1 relies on them, so we have to move them here.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   360
// !!! FIXME: If/when we kill off ARB1, we can move these back.
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   361
const char *get_D3D_varname_in_buf(Context *ctx, RegisterType rt,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   362
                                   int regnum, char *buf,
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   363
                                   const size_t len);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   364
const char *get_D3D_varname(Context *ctx, RegisterType rt, int regnum);
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff changeset
   365
1212
124155bb9bed GLSL: Implement texldl instruction
Katelyn Gadd <kg@luminance.org>
parents: 1199
diff changeset
   366
#endif