diff options
Diffstat (limited to 'third_party/webrender/swgl/src/program.h')
-rw-r--r-- | third_party/webrender/swgl/src/program.h | 82 |
1 files changed, 30 insertions, 52 deletions
diff --git a/third_party/webrender/swgl/src/program.h b/third_party/webrender/swgl/src/program.h index 9ea7c6dd6eb..80e5a5b68f7 100644 --- a/third_party/webrender/swgl/src/program.h +++ b/third_party/webrender/swgl/src/program.h @@ -12,12 +12,6 @@ namespace glsl { // to operate in Float-sized chunks. typedef vec3 Interpolants; -// Clip distances, if enabled, are always stored in the first SIMD chunk of the -// interpolants. -static ALWAYS_INLINE Float get_clip_distances(const Interpolants& interp) { - return interp.x; -} - struct VertexShaderImpl; struct FragmentShaderImpl; @@ -29,14 +23,10 @@ struct ProgramImpl { virtual size_t interpolants_size() const = 0; virtual VertexShaderImpl* get_vertex_shader() = 0; virtual FragmentShaderImpl* get_fragment_shader() = 0; - virtual const char* get_name() const = 0; }; typedef ProgramImpl* (*ProgramLoader)(); -// The maximum size of the gl_ClipDistance array. -constexpr int32_t gl_MaxClipDistances = 4; - struct VertexShaderImpl { typedef void (*SetUniform1iFunc)(VertexShaderImpl*, int index, int value); typedef void (*SetUniform4fvFunc)(VertexShaderImpl*, int index, @@ -56,17 +46,7 @@ struct VertexShaderImpl { LoadAttribsFunc load_attribs_func = nullptr; RunPrimitiveFunc run_primitive_func = nullptr; - enum FLAGS { - CLIP_DISTANCE = 1 << 0, - }; - int flags = 0; - void enable_clip_distance() { flags |= CLIP_DISTANCE; } - ALWAYS_INLINE bool use_clip_distance() const { - return (flags & CLIP_DISTANCE) != 0; - } - vec4 gl_Position; - Float gl_ClipDistance[gl_MaxClipDistances]; void set_uniform_1i(int index, int value) { (*set_uniform_1i_func)(this, index, value); @@ -92,20 +72,18 @@ struct VertexShaderImpl { } }; -// The number of pixels in a step. -constexpr int32_t swgl_StepSize = 4; - struct FragmentShaderImpl { typedef void (*InitSpanFunc)(FragmentShaderImpl*, const void* interps, - const void* step); + const void* step, float step_width); typedef void (*RunFunc)(FragmentShaderImpl*); - typedef void (*SkipFunc)(FragmentShaderImpl*, int steps); + typedef void (*SkipFunc)(FragmentShaderImpl*, int chunks); typedef void (*InitSpanWFunc)(FragmentShaderImpl*, const void* interps, - const void* step); + const void* step, float step_width); typedef void (*RunWFunc)(FragmentShaderImpl*); - typedef void (*SkipWFunc)(FragmentShaderImpl*, int steps); - typedef int (*DrawSpanRGBA8Func)(FragmentShaderImpl*); - typedef int (*DrawSpanR8Func)(FragmentShaderImpl*); + typedef void (*SkipWFunc)(FragmentShaderImpl*, int chunks); + typedef void (*DrawSpanRGBA8Func)(FragmentShaderImpl*, uint32_t* buf, + int len); + typedef void (*DrawSpanR8Func)(FragmentShaderImpl*, uint8_t* buf, int len); InitSpanFunc init_span_func = nullptr; RunFunc run_func = nullptr; @@ -129,27 +107,31 @@ struct FragmentShaderImpl { } vec4 gl_FragCoord; + vec2_scalar stepZW; + Bool isPixelDiscarded = false; vec4 gl_FragColor; vec4 gl_SecondaryFragColor; - vec2_scalar swgl_StepZW; - Bool swgl_IsPixelDiscarded = false; - // The current buffer position for committing span output. - uint32_t* swgl_OutRGBA8 = nullptr; - uint8_t* swgl_OutR8 = nullptr; - // The remaining number of pixels in the span. - int32_t swgl_SpanLength = 0; + ALWAYS_INLINE void step_fragcoord() { gl_FragCoord.x += 4; } - ALWAYS_INLINE void step_fragcoord(int steps = 4) { gl_FragCoord.x += steps; } + ALWAYS_INLINE void step_fragcoord(int chunks) { + gl_FragCoord.x += 4 * chunks; + } + + ALWAYS_INLINE void step_perspective() { + gl_FragCoord.z += stepZW.x; + gl_FragCoord.w += stepZW.y; + } - ALWAYS_INLINE void step_perspective(int steps = 4) { - gl_FragCoord.z += swgl_StepZW.x * steps; - gl_FragCoord.w += swgl_StepZW.y * steps; + ALWAYS_INLINE void step_perspective(int chunks) { + gl_FragCoord.z += stepZW.x * chunks; + gl_FragCoord.w += stepZW.y * chunks; } template <bool W = false> - ALWAYS_INLINE void init_span(const void* interps, const void* step) { - (*(W ? init_span_w_func : init_span_func))(this, interps, step); + ALWAYS_INLINE void init_span(const void* interps, const void* step, + float step_width) { + (*(W ? init_span_w_func : init_span_func))(this, interps, step, step_width); } template <bool W = false> @@ -158,24 +140,20 @@ struct FragmentShaderImpl { } template <bool W = false> - ALWAYS_INLINE void skip(int steps = 4) { - (*(W ? skip_w_func : skip_func))(this, steps); + ALWAYS_INLINE void skip(int chunks = 1) { + (*(W ? skip_w_func : skip_func))(this, chunks); } - ALWAYS_INLINE int draw_span(uint32_t* buf, int len) { - swgl_OutRGBA8 = buf; - swgl_SpanLength = len; - return (*draw_span_RGBA8_func)(this); + ALWAYS_INLINE void draw_span(uint32_t* buf, int len) { + (*draw_span_RGBA8_func)(this, buf, len); } ALWAYS_INLINE bool has_draw_span(uint32_t*) { return draw_span_RGBA8_func != nullptr; } - ALWAYS_INLINE int draw_span(uint8_t* buf, int len) { - swgl_OutR8 = buf; - swgl_SpanLength = len; - return (*draw_span_R8_func)(this); + ALWAYS_INLINE void draw_span(uint8_t* buf, int len) { + (*draw_span_R8_func)(this, buf, len); } ALWAYS_INLINE bool has_draw_span(uint8_t*) { |