mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 23:32:02 +00:00
Add codegen files for walls and columns
This commit is contained in:
parent
e5f3c119cd
commit
7be2511269
10 changed files with 279 additions and 180 deletions
|
@ -1447,7 +1447,10 @@ set (PCH_SOURCES
|
||||||
r_compiler/ssa/ssa_vec4i_ptr.cpp
|
r_compiler/ssa/ssa_vec4i_ptr.cpp
|
||||||
r_compiler/ssa/ssa_vec8s.cpp
|
r_compiler/ssa/ssa_vec8s.cpp
|
||||||
r_compiler/ssa/ssa_vec16ub.cpp
|
r_compiler/ssa/ssa_vec16ub.cpp
|
||||||
r_compiler/fixedfunction/fixedfunction.cpp
|
r_compiler/fixedfunction/drawercodegen.cpp
|
||||||
|
r_compiler/fixedfunction/drawspancodegen.cpp
|
||||||
|
r_compiler/fixedfunction/drawwallcodegen.cpp
|
||||||
|
r_compiler/fixedfunction/drawcolumncodegen.cpp
|
||||||
r_data/sprites.cpp
|
r_data/sprites.cpp
|
||||||
r_data/voxels.cpp
|
r_data/voxels.cpp
|
||||||
r_data/renderstyle.cpp
|
r_data/renderstyle.cpp
|
||||||
|
|
15
src/r_compiler/fixedfunction/drawcolumncodegen.cpp
Normal file
15
src/r_compiler/fixedfunction/drawcolumncodegen.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
#include "i_system.h"
|
||||||
|
#include "r_compiler/fixedfunction/drawcolumncodegen.h"
|
||||||
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
|
#include "r_compiler/ssa/ssa_scope.h"
|
||||||
|
#include "r_compiler/ssa/ssa_for_block.h"
|
||||||
|
#include "r_compiler/ssa/ssa_if_block.h"
|
||||||
|
#include "r_compiler/ssa/ssa_stack.h"
|
||||||
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
|
#include "r_compiler/ssa/ssa_struct_type.h"
|
||||||
|
#include "r_compiler/ssa/ssa_value.h"
|
||||||
|
|
||||||
|
void DrawColumnCodegen::Generate(DrawColumnVariant variant, SSAValue args)
|
||||||
|
{
|
||||||
|
}
|
26
src/r_compiler/fixedfunction/drawcolumncodegen.h
Normal file
26
src/r_compiler/fixedfunction/drawcolumncodegen.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "drawercodegen.h"
|
||||||
|
|
||||||
|
enum class DrawColumnVariant
|
||||||
|
{
|
||||||
|
Opaque,
|
||||||
|
Fuzz,
|
||||||
|
Add,
|
||||||
|
Translated,
|
||||||
|
TlatedAdd,
|
||||||
|
Shaded,
|
||||||
|
AddClamp,
|
||||||
|
AddClampTranslated,
|
||||||
|
SubClamp,
|
||||||
|
SubClampTranslated,
|
||||||
|
RevSubClamp,
|
||||||
|
RevSubClampTranslated
|
||||||
|
};
|
||||||
|
|
||||||
|
class DrawColumnCodegen : public DrawerCodegen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Generate(DrawColumnVariant variant, SSAValue args);
|
||||||
|
};
|
135
src/r_compiler/fixedfunction/drawercodegen.cpp
Normal file
135
src/r_compiler/fixedfunction/drawercodegen.cpp
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
|
||||||
|
#include "i_system.h"
|
||||||
|
#include "r_compiler/fixedfunction/drawercodegen.h"
|
||||||
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
|
#include "r_compiler/ssa/ssa_scope.h"
|
||||||
|
#include "r_compiler/ssa/ssa_for_block.h"
|
||||||
|
#include "r_compiler/ssa/ssa_if_block.h"
|
||||||
|
#include "r_compiler/ssa/ssa_stack.h"
|
||||||
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
|
#include "r_compiler/ssa/ssa_struct_type.h"
|
||||||
|
#include "r_compiler/ssa/ssa_value.h"
|
||||||
|
|
||||||
|
SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light)
|
||||||
|
{
|
||||||
|
return 256 - (light >> (FRACBITS - 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors)
|
||||||
|
{
|
||||||
|
SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index];
|
||||||
|
return shade_bgra_simple(color, light);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors)
|
||||||
|
{
|
||||||
|
SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index];
|
||||||
|
return shade_bgra_advanced(color, light, constants);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::shade_bgra_simple(SSAVec4i color, SSAInt light)
|
||||||
|
{
|
||||||
|
color = color * light / 256;
|
||||||
|
return color.insert(3, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants)
|
||||||
|
{
|
||||||
|
SSAInt blue = color[0];
|
||||||
|
SSAInt green = color[1];
|
||||||
|
SSAInt red = color[2];
|
||||||
|
SSAInt alpha = color[3];
|
||||||
|
|
||||||
|
SSAInt intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate;
|
||||||
|
|
||||||
|
SSAVec4i inv_light = 256 - light;
|
||||||
|
SSAVec4i inv_desaturate = 256 - constants.desaturate;
|
||||||
|
|
||||||
|
color = (color * inv_desaturate + intensity) / 256;
|
||||||
|
color = (constants.fade * inv_light + color * light) / 256;
|
||||||
|
color = (color * constants.light) / 256;
|
||||||
|
|
||||||
|
return color.insert(3, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::blend_copy(SSAVec4i fg)
|
||||||
|
{
|
||||||
|
return fg;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha)
|
||||||
|
{
|
||||||
|
SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256;
|
||||||
|
return color.insert(3, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha)
|
||||||
|
{
|
||||||
|
SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256;
|
||||||
|
return color.insert(3, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha)
|
||||||
|
{
|
||||||
|
SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256;
|
||||||
|
return color.insert(3, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg)
|
||||||
|
{
|
||||||
|
SSAInt alpha = fg[3];
|
||||||
|
alpha = alpha + (alpha >> 7); // // 255 -> 256
|
||||||
|
SSAInt inv_alpha = 256 - alpha;
|
||||||
|
SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256;
|
||||||
|
return color.insert(3, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha)
|
||||||
|
{
|
||||||
|
SSAInt alpha = fg[3];
|
||||||
|
alpha = alpha + (alpha >> 7);
|
||||||
|
SSAInt inv_alpha = 256 - alpha;
|
||||||
|
return (destalpha * alpha + 256 * inv_alpha + 128) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height)
|
||||||
|
{
|
||||||
|
SSAInt frac_y0 = (texturefracy >> FRACBITS) * height;
|
||||||
|
SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height;
|
||||||
|
SSAInt y0 = frac_y0 >> FRACBITS;
|
||||||
|
SSAInt y1 = frac_y1 >> FRACBITS;
|
||||||
|
|
||||||
|
SSAVec4i p00 = col0[y0 * 4].load_vec4ub();
|
||||||
|
SSAVec4i p01 = col0[y1 * 4].load_vec4ub();
|
||||||
|
SSAVec4i p10 = col1[y0 * 4].load_vec4ub();
|
||||||
|
SSAVec4i p11 = col1[y1 * 4].load_vec4ub();
|
||||||
|
|
||||||
|
SSAInt inv_b = texturefracx;
|
||||||
|
SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15;
|
||||||
|
SSAInt a = 16 - inv_a;
|
||||||
|
SSAInt b = 16 - inv_b;
|
||||||
|
|
||||||
|
return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits)
|
||||||
|
{
|
||||||
|
SSAInt xshift = (32 - xbits);
|
||||||
|
SSAInt yshift = (32 - ybits);
|
||||||
|
SSAInt xmask = (SSAInt(1) << xshift) - 1;
|
||||||
|
SSAInt ymask = (SSAInt(1) << yshift) - 1;
|
||||||
|
SSAInt x = xfrac >> xbits;
|
||||||
|
SSAInt y = yfrac >> ybits;
|
||||||
|
|
||||||
|
SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub();
|
||||||
|
SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub();
|
||||||
|
SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub();
|
||||||
|
SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub();
|
||||||
|
|
||||||
|
SSAInt inv_b = (xfrac >> (xbits - 4)) & 15;
|
||||||
|
SSAInt inv_a = (yfrac >> (ybits - 4)) & 15;
|
||||||
|
SSAInt a = 16 - inv_a;
|
||||||
|
SSAInt b = 16 - inv_b;
|
||||||
|
|
||||||
|
return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8;
|
||||||
|
}
|
|
@ -50,53 +50,3 @@ public:
|
||||||
SSAVec4i sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height);
|
SSAVec4i sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height);
|
||||||
SSAVec4i sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits);
|
SSAVec4i sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DrawSpanVariant
|
|
||||||
{
|
|
||||||
Opaque,
|
|
||||||
Masked,
|
|
||||||
Translucent,
|
|
||||||
MaskedTranslucent,
|
|
||||||
AddClamp,
|
|
||||||
MaskedAddClamp
|
|
||||||
};
|
|
||||||
|
|
||||||
class DrawSpanCodegen : public DrawerCodegen
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void Generate(DrawSpanVariant variant, SSAValue args);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void LoopShade(DrawSpanVariant variant, bool isSimpleShade);
|
|
||||||
void LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter);
|
|
||||||
SSAInt Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64);
|
|
||||||
void Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64);
|
|
||||||
SSAVec4i Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64);
|
|
||||||
SSAVec4i Shade(SSAVec4i fg, bool isSimpleShade);
|
|
||||||
SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant);
|
|
||||||
|
|
||||||
SSAStack<SSAInt> stack_index, stack_xfrac, stack_yfrac;
|
|
||||||
|
|
||||||
SSAUBytePtr destorg;
|
|
||||||
SSAUBytePtr source;
|
|
||||||
SSAInt destpitch;
|
|
||||||
SSAInt xstep;
|
|
||||||
SSAInt ystep;
|
|
||||||
SSAInt x1;
|
|
||||||
SSAInt x2;
|
|
||||||
SSAInt y;
|
|
||||||
SSAInt xbits;
|
|
||||||
SSAInt ybits;
|
|
||||||
SSAInt light;
|
|
||||||
SSAInt srcalpha;
|
|
||||||
SSAInt destalpha;
|
|
||||||
SSAInt count;
|
|
||||||
SSAUBytePtr data;
|
|
||||||
SSAInt yshift;
|
|
||||||
SSAInt xshift;
|
|
||||||
SSAInt xmask;
|
|
||||||
SSABool is_64x64;
|
|
||||||
SSABool is_simple_shade;
|
|
||||||
SSABool is_nearest_filter;
|
|
||||||
SSAShadeConstants shade_constants;
|
|
||||||
};
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "r_compiler/fixedfunction/fixedfunction.h"
|
#include "r_compiler/fixedfunction/drawspancodegen.h"
|
||||||
#include "r_compiler/ssa/ssa_function.h"
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
#include "r_compiler/ssa/ssa_scope.h"
|
#include "r_compiler/ssa/ssa_scope.h"
|
||||||
#include "r_compiler/ssa/ssa_for_block.h"
|
#include "r_compiler/ssa/ssa_for_block.h"
|
||||||
|
@ -9,7 +9,6 @@
|
||||||
#include "r_compiler/ssa/ssa_function.h"
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
#include "r_compiler/ssa/ssa_struct_type.h"
|
#include "r_compiler/ssa/ssa_struct_type.h"
|
||||||
#include "r_compiler/ssa/ssa_value.h"
|
#include "r_compiler/ssa/ssa_value.h"
|
||||||
#include "r_compiler/ssa/ssa_barycentric_weight.h"
|
|
||||||
|
|
||||||
void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args)
|
void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args)
|
||||||
{
|
{
|
||||||
|
@ -200,129 +199,3 @@ SSAVec4i DrawSpanCodegen::Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant varian
|
||||||
return blend_add(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
return blend_add(fg, bg, srcalpha, calc_blend_bgalpha(fg, destalpha));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
SSAInt DrawerCodegen::calc_light_multiplier(SSAInt light)
|
|
||||||
{
|
|
||||||
return 256 - (light >> (FRACBITS - 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::shade_pal_index_simple(SSAInt index, SSAInt light, SSAUBytePtr basecolors)
|
|
||||||
{
|
|
||||||
SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index];
|
|
||||||
return shade_bgra_simple(color, light);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::shade_pal_index_advanced(SSAInt index, SSAInt light, const SSAShadeConstants &constants, SSAUBytePtr basecolors)
|
|
||||||
{
|
|
||||||
SSAVec4i color = basecolors[index * 4].load_vec4ub(); // = GPalette.BaseColors[index];
|
|
||||||
return shade_bgra_advanced(color, light, constants);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::shade_bgra_simple(SSAVec4i color, SSAInt light)
|
|
||||||
{
|
|
||||||
color = color * light / 256;
|
|
||||||
return color.insert(3, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::shade_bgra_advanced(SSAVec4i color, SSAInt light, const SSAShadeConstants &constants)
|
|
||||||
{
|
|
||||||
SSAInt blue = color[0];
|
|
||||||
SSAInt green = color[1];
|
|
||||||
SSAInt red = color[2];
|
|
||||||
SSAInt alpha = color[3];
|
|
||||||
|
|
||||||
SSAInt intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate;
|
|
||||||
|
|
||||||
SSAVec4i inv_light = 256 - light;
|
|
||||||
SSAVec4i inv_desaturate = 256 - constants.desaturate;
|
|
||||||
|
|
||||||
color = (color * inv_desaturate + intensity) / 256;
|
|
||||||
color = (constants.fade * inv_light + color * light) / 256;
|
|
||||||
color = (color * constants.light) / 256;
|
|
||||||
|
|
||||||
return color.insert(3, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::blend_copy(SSAVec4i fg)
|
|
||||||
{
|
|
||||||
return fg;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::blend_add(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha)
|
|
||||||
{
|
|
||||||
SSAVec4i color = (fg * srcalpha + bg * destalpha) / 256;
|
|
||||||
return color.insert(3, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::blend_sub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha)
|
|
||||||
{
|
|
||||||
SSAVec4i color = (bg * destalpha - fg * srcalpha) / 256;
|
|
||||||
return color.insert(3, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::blend_revsub(SSAVec4i fg, SSAVec4i bg, SSAInt srcalpha, SSAInt destalpha)
|
|
||||||
{
|
|
||||||
SSAVec4i color = (fg * srcalpha - bg * destalpha) / 256;
|
|
||||||
return color.insert(3, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::blend_alpha_blend(SSAVec4i fg, SSAVec4i bg)
|
|
||||||
{
|
|
||||||
SSAInt alpha = fg[3];
|
|
||||||
alpha = alpha + (alpha >> 7); // // 255 -> 256
|
|
||||||
SSAInt inv_alpha = 256 - alpha;
|
|
||||||
SSAVec4i color = (fg * alpha + bg * inv_alpha) / 256;
|
|
||||||
return color.insert(3, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha)
|
|
||||||
{
|
|
||||||
SSAInt alpha = fg[3];
|
|
||||||
alpha = alpha + (alpha >> 7);
|
|
||||||
SSAInt inv_alpha = 256 - alpha;
|
|
||||||
return (destalpha * alpha + 256 * inv_alpha + 128) >> 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height)
|
|
||||||
{
|
|
||||||
SSAInt frac_y0 = (texturefracy >> FRACBITS) * height;
|
|
||||||
SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height;
|
|
||||||
SSAInt y0 = frac_y0 >> FRACBITS;
|
|
||||||
SSAInt y1 = frac_y1 >> FRACBITS;
|
|
||||||
|
|
||||||
SSAVec4i p00 = col0[y0 * 4].load_vec4ub();
|
|
||||||
SSAVec4i p01 = col0[y1 * 4].load_vec4ub();
|
|
||||||
SSAVec4i p10 = col1[y0 * 4].load_vec4ub();
|
|
||||||
SSAVec4i p11 = col1[y1 * 4].load_vec4ub();
|
|
||||||
|
|
||||||
SSAInt inv_b = texturefracx;
|
|
||||||
SSAInt inv_a = (frac_y1 >> (FRACBITS - 4)) & 15;
|
|
||||||
SSAInt a = 16 - inv_a;
|
|
||||||
SSAInt b = 16 - inv_b;
|
|
||||||
|
|
||||||
return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits)
|
|
||||||
{
|
|
||||||
SSAInt xshift = (32 - xbits);
|
|
||||||
SSAInt yshift = (32 - ybits);
|
|
||||||
SSAInt xmask = (SSAInt(1) << xshift) - 1;
|
|
||||||
SSAInt ymask = (SSAInt(1) << yshift) - 1;
|
|
||||||
SSAInt x = xfrac >> xbits;
|
|
||||||
SSAInt y = yfrac >> ybits;
|
|
||||||
|
|
||||||
SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub();
|
|
||||||
SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub();
|
|
||||||
SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub();
|
|
||||||
SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub();
|
|
||||||
|
|
||||||
SSAInt inv_b = (xfrac >> (xbits - 4)) & 15;
|
|
||||||
SSAInt inv_a = (yfrac >> (ybits - 4)) & 15;
|
|
||||||
SSAInt a = 16 - inv_a;
|
|
||||||
SSAInt b = 16 - inv_b;
|
|
||||||
|
|
||||||
return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8;
|
|
||||||
}
|
|
54
src/r_compiler/fixedfunction/drawspancodegen.h
Normal file
54
src/r_compiler/fixedfunction/drawspancodegen.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "drawercodegen.h"
|
||||||
|
|
||||||
|
enum class DrawSpanVariant
|
||||||
|
{
|
||||||
|
Opaque,
|
||||||
|
Masked,
|
||||||
|
Translucent,
|
||||||
|
MaskedTranslucent,
|
||||||
|
AddClamp,
|
||||||
|
MaskedAddClamp
|
||||||
|
};
|
||||||
|
|
||||||
|
class DrawSpanCodegen : public DrawerCodegen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Generate(DrawSpanVariant variant, SSAValue args);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void LoopShade(DrawSpanVariant variant, bool isSimpleShade);
|
||||||
|
void LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter);
|
||||||
|
SSAInt Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64);
|
||||||
|
void Loop(SSAInt start, DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64);
|
||||||
|
SSAVec4i Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilter, bool is64x64);
|
||||||
|
SSAVec4i Shade(SSAVec4i fg, bool isSimpleShade);
|
||||||
|
SSAVec4i Blend(SSAVec4i fg, SSAVec4i bg, DrawSpanVariant variant);
|
||||||
|
|
||||||
|
SSAStack<SSAInt> stack_index, stack_xfrac, stack_yfrac;
|
||||||
|
|
||||||
|
SSAUBytePtr destorg;
|
||||||
|
SSAUBytePtr source;
|
||||||
|
SSAInt destpitch;
|
||||||
|
SSAInt xstep;
|
||||||
|
SSAInt ystep;
|
||||||
|
SSAInt x1;
|
||||||
|
SSAInt x2;
|
||||||
|
SSAInt y;
|
||||||
|
SSAInt xbits;
|
||||||
|
SSAInt ybits;
|
||||||
|
SSAInt light;
|
||||||
|
SSAInt srcalpha;
|
||||||
|
SSAInt destalpha;
|
||||||
|
SSAInt count;
|
||||||
|
SSAUBytePtr data;
|
||||||
|
SSAInt yshift;
|
||||||
|
SSAInt xshift;
|
||||||
|
SSAInt xmask;
|
||||||
|
SSABool is_64x64;
|
||||||
|
SSABool is_simple_shade;
|
||||||
|
SSABool is_nearest_filter;
|
||||||
|
SSAShadeConstants shade_constants;
|
||||||
|
};
|
15
src/r_compiler/fixedfunction/drawwallcodegen.cpp
Normal file
15
src/r_compiler/fixedfunction/drawwallcodegen.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
#include "i_system.h"
|
||||||
|
#include "r_compiler/fixedfunction/drawwallcodegen.h"
|
||||||
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
|
#include "r_compiler/ssa/ssa_scope.h"
|
||||||
|
#include "r_compiler/ssa/ssa_for_block.h"
|
||||||
|
#include "r_compiler/ssa/ssa_if_block.h"
|
||||||
|
#include "r_compiler/ssa/ssa_stack.h"
|
||||||
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
|
#include "r_compiler/ssa/ssa_struct_type.h"
|
||||||
|
#include "r_compiler/ssa/ssa_value.h"
|
||||||
|
|
||||||
|
void DrawWallCodegen::Generate(DrawWallVariant variant, SSAValue args)
|
||||||
|
{
|
||||||
|
}
|
26
src/r_compiler/fixedfunction/drawwallcodegen.h
Normal file
26
src/r_compiler/fixedfunction/drawwallcodegen.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "drawercodegen.h"
|
||||||
|
|
||||||
|
enum class DrawWallVariant
|
||||||
|
{
|
||||||
|
Opaque1, // vlinec1
|
||||||
|
Opaque4, // vlinec4
|
||||||
|
Masked1, // mvlinec1
|
||||||
|
Masked4, // mvlinec4
|
||||||
|
Add1, // tmvline1_add
|
||||||
|
Add4, // tmvline4_add
|
||||||
|
AddClamp1, // tmvline1_addclamp
|
||||||
|
AddClamp4, // tmvline4_addclamp
|
||||||
|
SubClamp1, // tmvline1_subclamp
|
||||||
|
SubClamp4, // tmvline4_subclamp
|
||||||
|
RevSubClamp1, // tmvline1_revsubclamp
|
||||||
|
RevSubClamp4, // tmvline4_revsubclamp
|
||||||
|
};
|
||||||
|
|
||||||
|
class DrawWallCodegen : public DrawerCodegen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Generate(DrawWallVariant variant, SSAValue args);
|
||||||
|
};
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "r_compiler/fixedfunction/fixedfunction.h"
|
#include "r_compiler/fixedfunction/drawspancodegen.h"
|
||||||
|
#include "r_compiler/fixedfunction/drawwallcodegen.h"
|
||||||
|
#include "r_compiler/fixedfunction/drawcolumncodegen.h"
|
||||||
#include "r_compiler/ssa/ssa_function.h"
|
#include "r_compiler/ssa/ssa_function.h"
|
||||||
#include "r_compiler/ssa/ssa_scope.h"
|
#include "r_compiler/ssa/ssa_scope.h"
|
||||||
#include "r_compiler/ssa/ssa_for_block.h"
|
#include "r_compiler/ssa/ssa_for_block.h"
|
||||||
|
|
Loading…
Reference in a new issue