This commit is contained in:
RobertoFresca 2016-08-12 02:58:04 -03:00
commit f6ef75e4b9
1356 changed files with 24840 additions and 15176 deletions

View File

@ -1,6 +1,23 @@
GLSL optimizer Change Log
=========================
2016 06
-------
Fixed:
* Fixed Metal translation in some cases having wrong precision on constants or constant arrays.
2016 05
-------
Fixed:
* Fixed Metal translation in some cases having wrong precision on struct members.
* Fixed Metal translation in some cases emitting struct declarations vs. constant initializers in wrong order.
2016 03
-------

View File

@ -3042,6 +3042,12 @@ process_initializer(ir_variable *var, ast_declaration *decl,
ir_dereference *const lhs = new(state) ir_dereference_variable(var);
ir_rvalue *rhs = decl->initializer->hir(initializer_instructions, state);
/* Propagate precision qualifier for constant value */
if (type->qualifier.flags.q.constant) {
ir_constant *constant_value = rhs->constant_expression_value();
constant_value->set_precision((glsl_precision)type->qualifier.precision);
}
/* Calculate the constant value if this is a const or uniform
* declaration.
*/

View File

@ -647,8 +647,8 @@ ir_constant::ir_constant()
}
ir_constant::ir_constant(const struct glsl_type *type,
const ir_constant_data *data)
: ir_rvalue(ir_type_constant, glsl_precision_undefined)
const ir_constant_data *data, glsl_precision precision)
: ir_rvalue(ir_type_constant, precision)
{
assert((type->base_type >= GLSL_TYPE_UINT)
&& (type->base_type <= GLSL_TYPE_BOOL));

View File

@ -2161,7 +2161,7 @@ union ir_constant_data {
class ir_constant : public ir_rvalue {
public:
ir_constant(const struct glsl_type *type, const ir_constant_data *data);
ir_constant(const struct glsl_type *type, const ir_constant_data *data, glsl_precision precision = glsl_precision_undefined);
ir_constant(bool b, unsigned vector_elements=1);
ir_constant(unsigned int u, unsigned vector_elements=1);
ir_constant(int i, unsigned vector_elements=1);

View File

@ -330,7 +330,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
case GLSL_TYPE_INT:
case GLSL_TYPE_FLOAT:
case GLSL_TYPE_BOOL:
return new(mem_ctx) ir_constant(this->type, &this->value);
return new(mem_ctx) ir_constant(this->type, &this->value, this->precision);
case GLSL_TYPE_STRUCT: {
ir_constant *c = new(mem_ctx) ir_constant;
@ -351,6 +351,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
ir_constant *c = new(mem_ctx) ir_constant;
c->type = this->type;
c->set_precision(this->get_precision());
c->array_elements = ralloc_array(c, ir_constant *, this->type->length);
for (unsigned i = 0; i < this->type->length; i++) {
c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL);

View File

@ -99,6 +99,7 @@ struct metal_print_context
, inoutStr(ralloc_strdup(buffer, ""))
, uniformStr(ralloc_strdup(buffer, ""))
, paramsStr(ralloc_strdup(buffer, ""))
, typedeclStr(ralloc_strdup(buffer, ""))
, writingParams(false)
, matrixCastsDone(false)
, matrixConstructorsDone(false)
@ -117,6 +118,7 @@ struct metal_print_context
string_buffer inoutStr;
string_buffer uniformStr;
string_buffer paramsStr;
string_buffer typedeclStr;
bool writingParams;
bool matrixCastsDone;
bool matrixConstructorsDone;
@ -268,6 +270,9 @@ _mesa_print_ir_metal(exec_list *instructions,
strOut = &ctx.inoutStr;
}
if (ir->ir_type == ir_type_typedecl) {
strOut = &ctx.typedeclStr;
}
ir_print_metal_visitor v (ctx, *strOut, &gtracker, mode, state);
v.loopstate = ls;
@ -293,6 +298,8 @@ _mesa_print_ir_metal(exec_list *instructions,
ctx.uniformStr.asprintf_append("};\n");
// emit global array/struct constants
ctx.prefixStr.asprintf_append("%s", ctx.typedeclStr.c_str());
foreach_in_list_safe(gconst_entry_metal, node, &gtracker.global_constants)
{
ir_constant* c = node->ir;
@ -1968,7 +1975,7 @@ ir_print_metal_visitor::visit(ir_typedecl_statement *ir)
buffer.asprintf_append (" ");
//if (state->es_shader)
// buffer.asprintf_append ("%s", get_precision_string(s->fields.structure[j].precision)); //@TODO
print_type(buffer, ir, s->fields.structure[j].type, false);
print_type_precision(buffer, s->fields.structure[j].type, s->fields.structure[j].precision, false);
buffer.asprintf_append (" %s", s->fields.structure[j].name);
print_type_post(buffer, s->fields.structure[j].type, false);
buffer.asprintf_append (";\n");

View File

@ -0,0 +1,40 @@
#version 300 es
#define gl_FragData _glesFragData
layout(location = 0) out mediump vec4 _glesFragData[1];
struct v2f {
highp vec4 pos;
mediump vec2 uv;
};
struct u2v {
highp vec4 vertex;
mediump vec2 texcoord;
};
const mediump vec3[3] ha = vec3[3]( vec3( 1.0, 2.0, 3.0), vec3( 4.0, 5.0, 6.0), vec3( 7.0, 8.0, 9.0));
const highp vec3[3] fa = vec3[3]( vec3( 11.0, 12.0, 13.0), vec3( 14.0, 15.0, 16.0), vec3( 17.0, 18.0, 19.0));
mediump vec4 frag( in v2f i ) {
mediump vec3 h = vec3( 0.0);
highp vec3 f = vec3( 0.0);
highp vec3 p = vec3( i.uv.xy, 1.0);
highp int j = 0;
for ( ; (j < int((i.uv.x * 3.0))); (j++)) {
h += ha[j];
f += fa[j];
f += (p * ha[0]);
}
return vec4( h.xy, f.xy);
}
in mediump vec2 xlv_TEXCOORD0;
void main() {
mediump vec4 xl_retval;
v2f xlt_i;
xlt_i.pos = vec4(0.0);
xlt_i.uv = vec2(xlv_TEXCOORD0);
xl_retval = frag( xlt_i);
gl_FragData[0] = vec4(xl_retval);
}

View File

@ -0,0 +1,33 @@
#version 300 es
layout(location=0) out mediump vec4 _glesFragData[1];
in mediump vec2 xlv_TEXCOORD0;
void main ()
{
mediump vec4 tmpvar_1;
mediump vec2 tmpvar_2;
tmpvar_2 = xlv_TEXCOORD0;
highp vec3 p_4;
highp vec3 f_5;
mediump vec3 h_6;
h_6 = vec3(0.0, 0.0, 0.0);
f_5 = vec3(0.0, 0.0, 0.0);
mediump vec3 tmpvar_7;
tmpvar_7.z = 1.0;
tmpvar_7.xy = xlv_TEXCOORD0;
p_4 = tmpvar_7;
for (highp int j_3 = 0; j_3 < int((tmpvar_2.x * 3.0)); j_3++) {
h_6 = (h_6 + vec3[3](vec3(1.0, 2.0, 3.0), vec3(4.0, 5.0, 6.0), vec3(7.0, 8.0, 9.0))[j_3]);
f_5 = (f_5 + vec3[3](vec3(11.0, 12.0, 13.0), vec3(14.0, 15.0, 16.0), vec3(17.0, 18.0, 19.0))[j_3]);
f_5 = (f_5 + (p_4 * vec3(1.0, 2.0, 3.0)));
};
highp vec4 tmpvar_8;
tmpvar_8.xy = h_6.xy;
tmpvar_8.zw = f_5.xy;
tmpvar_1 = tmpvar_8;
_glesFragData[0] = tmpvar_1;
}
// stats: 12 alu 0 tex 2 flow
// inputs: 1
// #0: xlv_TEXCOORD0 (medium float) 2x1 [-1]

View File

@ -0,0 +1,45 @@
#include <metal_stdlib>
#pragma clang diagnostic ignored "-Wparentheses-equality"
using namespace metal;
constant half3 _xlat_mtl_const1[3] = {float3(1.0, 2.0, 3.0), float3(4.0, 5.0, 6.0), float3(7.0, 8.0, 9.0)};
constant float3 _xlat_mtl_const2[3] = {float3(11.0, 12.0, 13.0), float3(14.0, 15.0, 16.0), float3(17.0, 18.0, 19.0)};
struct xlatMtlShaderInput {
half2 xlv_TEXCOORD0;
};
struct xlatMtlShaderOutput {
half4 _glesFragData_0 [[color(0)]];
};
struct xlatMtlShaderUniform {
};
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
{
xlatMtlShaderOutput _mtl_o;
half4 tmpvar_1;
half2 tmpvar_2;
tmpvar_2 = _mtl_i.xlv_TEXCOORD0;
float3 p_4;
float3 f_5;
half3 h_6;
h_6 = half3(float3(0.0, 0.0, 0.0));
f_5 = float3(0.0, 0.0, 0.0);
half3 tmpvar_7;
tmpvar_7.z = half(1.0);
tmpvar_7.xy = _mtl_i.xlv_TEXCOORD0;
p_4 = float3(tmpvar_7);
for (int j_3 = 0; j_3 < short((tmpvar_2.x * (half)3.0)); j_3++) {
h_6 = (h_6 + _xlat_mtl_const1[j_3]);
f_5 = (f_5 + _xlat_mtl_const2[j_3]);
f_5 = (f_5 + (p_4 * float3(1.0, 2.0, 3.0)));
};
float4 tmpvar_8;
tmpvar_8.xy = float2(h_6.xy);
tmpvar_8.zw = f_5.xy;
tmpvar_1 = half4(tmpvar_8);
_mtl_o._glesFragData_0 = tmpvar_1;
return _mtl_o;
}
// stats: 12 alu 0 tex 2 flow
// inputs: 1
// #0: xlv_TEXCOORD0 (medium float) 2x1 [-1]

View File

@ -0,0 +1,685 @@
#version 300 es
vec4 xll_texCUBElod(samplerCube s, vec4 coord) {
return textureLod( s, coord.xyz, coord.w);
}
float xll_shadow2D(mediump sampler2DShadow s, vec3 coord) { return texture (s, coord); }
float xll_saturate_f( float x) {
return clamp( x, 0.0, 1.0);
}
vec2 xll_saturate_vf2( vec2 x) {
return clamp( x, 0.0, 1.0);
}
vec3 xll_saturate_vf3( vec3 x) {
return clamp( x, 0.0, 1.0);
}
vec4 xll_saturate_vf4( vec4 x) {
return clamp( x, 0.0, 1.0);
}
mat2 xll_saturate_mf2x2(mat2 m) {
return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0));
}
mat3 xll_saturate_mf3x3(mat3 m) {
return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0));
}
mat4 xll_saturate_mf4x4(mat4 m) {
return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0));
}
struct v2f_vertex_lit {
highp vec2 uv;
lowp vec4 diff;
lowp vec4 spec;
};
struct v2f_img {
highp vec4 pos;
mediump vec2 uv;
};
struct appdata_img {
highp vec4 vertex;
mediump vec2 texcoord;
};
struct Unity_GlossyEnvironmentData {
mediump float roughness;
mediump vec3 reflUVW;
};
struct UnityLight {
mediump vec3 color;
mediump vec3 dir;
mediump float ndotl;
};
struct UnityIndirect {
mediump vec3 diffuse;
mediump vec3 specular;
};
struct UnityGI {
UnityLight light;
UnityIndirect indirect;
};
struct UnityGIInput {
UnityLight light;
highp vec3 worldPos;
mediump vec3 worldViewDir;
mediump float atten;
mediump vec3 ambient;
mediump vec4 lightmapUV;
highp vec4 boxMax[2];
highp vec4 boxMin[2];
highp vec4 probePosition[2];
highp vec4 probeHDR[2];
};
struct SurfaceOutputStandard {
lowp vec3 Albedo;
lowp vec3 Normal;
mediump vec3 Emission;
mediump float Metallic;
mediump float Smoothness;
mediump float Occlusion;
lowp float Alpha;
};
struct SurfaceOutputStandardSpecular {
lowp vec3 Albedo;
lowp vec3 Specular;
lowp vec3 Normal;
mediump vec3 Emission;
mediump float Smoothness;
mediump float Occlusion;
lowp float Alpha;
};
struct VertexInput {
highp vec4 vertex;
mediump vec3 normal;
highp vec2 uv0;
highp vec2 uv1;
};
struct FragmentCommonData {
mediump vec3 diffColor;
mediump vec3 specColor;
mediump float oneMinusReflectivity;
mediump float oneMinusRoughness;
mediump vec3 normalWorld;
mediump vec3 eyeVec;
mediump vec3 posWorld;
mediump float alpha;
};
struct VertexOutputForwardBase {
highp vec4 pos;
highp vec4 tex;
mediump vec3 eyeVec;
mediump vec4 tangentToWorldAndParallax[3];
mediump vec4 ambientOrLightmapUV;
mediump vec4 _ShadowCoord;
};
struct VertexOutputForwardAdd {
highp vec4 pos;
highp vec4 tex;
mediump vec3 eyeVec;
mediump vec4 tangentToWorldAndLightDir[3];
mediump vec4 _ShadowCoord;
};
struct VertexOutputDeferred {
highp vec4 pos;
highp vec4 tex;
mediump vec3 eyeVec;
mediump vec4 tangentToWorldAndParallax[3];
mediump vec4 ambientOrLightmapUV;
};
struct VertexInput_VC {
highp vec4 vertex;
lowp vec4 color;
mediump vec3 normal;
highp vec2 uv0;
highp vec2 uv1;
};
struct VertexOutputForwardBase_VC {
highp vec4 pos;
highp vec4 tex;
mediump vec3 eyeVec;
mediump vec4 tangentToWorldAndParallax[3];
mediump vec4 ambientOrLightmapUV;
mediump vec4 _ShadowCoord;
lowp vec4 color;
};
struct VertexOutputDeferred_VC {
highp vec4 pos;
lowp vec4 color;
highp vec4 tex;
mediump vec3 eyeVec;
mediump vec4 tangentToWorldAndParallax[3];
mediump vec4 ambientOrLightmapUV;
};
uniform highp vec4 _Time;
uniform highp vec4 _SinTime;
uniform highp vec4 _CosTime;
uniform highp vec4 unity_DeltaTime;
uniform highp vec3 _WorldSpaceCameraPos;
uniform highp vec4 _ProjectionParams;
uniform highp vec4 _ScreenParams;
uniform highp vec4 _ZBufferParams;
uniform highp vec4 unity_OrthoParams;
uniform highp vec4 unity_CameraWorldClipPlanes[6];
uniform highp mat4 unity_CameraProjection;
uniform highp mat4 unity_CameraInvProjection;
uniform mediump vec4 _WorldSpaceLightPos0;
uniform highp vec4 _LightPositionRange;
uniform highp vec4 unity_4LightPosX0;
uniform highp vec4 unity_4LightPosY0;
uniform highp vec4 unity_4LightPosZ0;
uniform mediump vec4 unity_4LightAtten0;
uniform mediump vec4 unity_LightColor[8];
uniform highp vec4 unity_LightPosition[8];
uniform mediump vec4 unity_LightAtten[8];
uniform highp vec4 unity_SpotDirection[8];
uniform mediump vec4 unity_SHAr;
uniform mediump vec4 unity_SHAg;
uniform mediump vec4 unity_SHAb;
uniform mediump vec4 unity_SHBr;
uniform mediump vec4 unity_SHBg;
uniform mediump vec4 unity_SHBb;
uniform mediump vec4 unity_SHC;
uniform mediump vec3 unity_LightColor0;
uniform mediump vec3 unity_LightColor1;
uniform mediump vec3 unity_LightColor2;
uniform mediump vec3 unity_LightColor3;
uniform highp vec4 unity_ShadowSplitSpheres[4];
uniform highp vec4 unity_ShadowSplitSqRadii;
uniform highp vec4 unity_LightShadowBias;
uniform highp vec4 _LightSplitsNear;
uniform highp vec4 _LightSplitsFar;
uniform highp mat4 unity_World2Shadow[4];
uniform mediump vec4 _LightShadowData;
uniform highp vec4 unity_ShadowFadeCenterAndType;
uniform highp mat4 glstate_matrix_mvp;
uniform highp mat4 glstate_matrix_modelview0;
uniform highp mat4 glstate_matrix_invtrans_modelview0;
uniform highp mat4 _Object2World;
uniform highp mat4 _World2Object;
uniform highp vec4 unity_LODFade;
uniform highp vec4 unity_WorldTransformParams;
uniform highp mat4 glstate_matrix_transpose_modelview0;
uniform highp mat4 glstate_matrix_projection;
uniform lowp vec4 glstate_lightmodel_ambient;
uniform highp mat4 unity_MatrixV;
uniform highp mat4 unity_MatrixVP;
uniform lowp vec4 unity_AmbientSky;
uniform lowp vec4 unity_AmbientEquator;
uniform lowp vec4 unity_AmbientGround;
uniform lowp vec4 unity_FogColor;
uniform highp vec4 unity_FogParams;
uniform sampler2D unity_Lightmap;
uniform sampler2D unity_LightmapInd;
uniform sampler2D unity_DynamicLightmap;
uniform sampler2D unity_DynamicDirectionality;
uniform sampler2D unity_DynamicNormal;
uniform highp vec4 unity_LightmapST;
uniform highp vec4 unity_DynamicLightmapST;
uniform samplerCube unity_SpecCube0;
uniform samplerCube unity_SpecCube1;
uniform highp vec4 unity_SpecCube0_BoxMax;
uniform highp vec4 unity_SpecCube0_BoxMin;
uniform highp vec4 unity_SpecCube0_ProbePosition;
uniform mediump vec4 unity_SpecCube0_HDR;
uniform highp vec4 unity_SpecCube1_BoxMax;
uniform highp vec4 unity_SpecCube1_BoxMin;
uniform highp vec4 unity_SpecCube1_ProbePosition;
uniform mediump vec4 unity_SpecCube1_HDR;
uniform lowp vec4 unity_ColorSpaceGrey;
uniform lowp vec4 unity_ColorSpaceDouble;
uniform mediump vec4 unity_ColorSpaceDielectricSpec;
uniform mediump vec4 unity_ColorSpaceLuminance;
uniform mediump vec4 unity_Lightmap_HDR;
uniform mediump vec4 unity_DynamicLightmap_HDR;
uniform lowp vec4 _LightColor0;
uniform lowp vec4 _SpecColor;
uniform sampler2D unity_NHxRoughness;
uniform mediump vec4 _Color;
uniform mediump float _Cutoff;
uniform sampler2D _MainTex;
uniform highp vec4 _MainTex_ST;
uniform sampler2D _DetailAlbedoMap;
uniform highp vec4 _DetailAlbedoMap_ST;
uniform sampler2D _BumpMap;
uniform mediump float _BumpScale;
uniform sampler2D _DetailMask;
uniform sampler2D _DetailNormalMap;
uniform mediump float _DetailNormalMapScale;
uniform sampler2D _SpecGlossMap;
uniform sampler2D _MetallicGlossMap;
uniform mediump float _Metallic;
uniform mediump float _Glossiness;
uniform sampler2D _OcclusionMap;
uniform mediump float _OcclusionStrength;
uniform sampler2D _ParallaxMap;
uniform mediump float _Parallax;
uniform mediump float _UVSec;
uniform mediump vec4 _EmissionColor;
uniform sampler2D _EmissionMap;
uniform lowp sampler2DShadow _ShadowMapTexture;
mediump float DotClamped( in mediump vec3 a, in mediump vec3 b ) {
return max( 0.0, dot( a, b));
}
mediump float BlinnTerm( in mediump vec3 normal, in mediump vec3 halfDir ) {
return DotClamped( normal, halfDir);
}
mediump float Pow4( in mediump float x ) {
return (((x * x) * x) * x);
}
mediump vec3 FresnelLerpFast( in mediump vec3 F0, in mediump vec3 F90, in mediump float cosA ) {
mediump float t = Pow4( (1.0 - cosA));
return mix( F0, F90, vec3( t));
}
bool IsGammaSpace( ) {
return true;
}
mediump float RoughnessToSpecPower( in mediump float roughness ) {
mediump float m = max( 0.0001, (roughness * roughness));
mediump float n = ((2.0 / (m * m)) - 2.0);
n = max( n, 0.0001);
return n;
}
mediump vec3 Unity_SafeNormalize( in mediump vec3 inVec ) {
mediump float dp3 = max( 0.001, dot( inVec, inVec));
return (inVec * inversesqrt(dp3));
}
mediump vec4 BRDF2_Unity_PBS( in mediump vec3 diffColor, in mediump vec3 specColor, in mediump float oneMinusReflectivity, in mediump float oneMinusRoughness, in mediump vec3 normal, in mediump vec3 viewDir, in UnityLight light, in UnityIndirect gi ) {
mediump vec3 halfDir = Unity_SafeNormalize( (light.dir + viewDir));
mediump float nl = light.ndotl;
mediump float nh = BlinnTerm( normal, halfDir);
mediump float nv = DotClamped( normal, viewDir);
mediump float lh = DotClamped( light.dir, halfDir);
mediump float roughness = (1.0 - oneMinusRoughness);
mediump float specularPower = RoughnessToSpecPower( roughness);
mediump float invV = (((lh * lh) * oneMinusRoughness) + (roughness * roughness));
mediump float invF = lh;
mediump float specular = (((specularPower + 1.0) * pow( nh, specularPower)) / (((8.0 * invV) * invF) + 0.0001));
if (IsGammaSpace( )){
specular = sqrt(max( 0.0001, specular));
}
mediump float realRoughness = (roughness * roughness);
mediump float surfaceReduction = (( IsGammaSpace( ) ) ? ( 0.28 ) : ( (0.6 - (0.08 * roughness)) ));
surfaceReduction = (1.0 - ((realRoughness * roughness) * surfaceReduction));
mediump float grazingTerm = xll_saturate_f((oneMinusRoughness + (1.0 - oneMinusReflectivity)));
mediump vec3 color = (((((diffColor + (specular * specColor)) * light.color) * nl) + (gi.diffuse * diffColor)) + ((surfaceReduction * gi.specular) * FresnelLerpFast( specColor, vec3( grazingTerm), nv)));
return vec4( color, 1.0);
}
mediump vec3 BRDF_Unity_Indirect( in mediump vec3 baseColor, in mediump vec3 specColor, in mediump float oneMinusReflectivity, in mediump float oneMinusRoughness, in mediump vec3 normal, in mediump vec3 viewDir, in mediump float occlusion, in UnityGI gi ) {
mediump vec3 c = vec3( 0.0);
return c;
}
mediump vec3 Emission( in highp vec2 uv ) {
return vec3( 0.0);
}
void ResetUnityLight( out UnityLight outLight ) {
outLight.color = vec3( 0.0);
outLight.dir = vec3( 0.0);
outLight.ndotl = 0.0;
}
void ResetUnityGI( out UnityGI outGI ) {
ResetUnityLight( outGI.light);
outGI.indirect.diffuse = vec3( 0.0);
outGI.indirect.specular = vec3( 0.0);
}
mediump vec3 LinearToGammaSpace( in mediump vec3 linRGB ) {
linRGB = max( linRGB, vec3( 0.0, 0.0, 0.0));
return max( ((1.055 * pow( linRGB, vec3( 0.4166667))) - 0.055), vec3( 0.0));
}
mediump vec3 SHEvalLinearL0L1( in mediump vec4 normal ) {
mediump vec3 x;
x.x = dot( unity_SHAr, normal);
x.y = dot( unity_SHAg, normal);
x.z = dot( unity_SHAb, normal);
return x;
}
mediump vec3 ShadeSHPerPixel( in mediump vec3 normal, in mediump vec3 ambient ) {
mediump vec3 ambient_contrib = vec3( 0.0);
ambient_contrib = SHEvalLinearL0L1( vec4( normal, 1.0));
ambient = max( vec3( 0.0, 0.0, 0.0), (ambient + ambient_contrib));
if (IsGammaSpace( )){
ambient = LinearToGammaSpace( ambient);
}
return ambient;
}
UnityGI UnityGI_Base( in UnityGIInput data, in mediump float occlusion, in mediump vec3 normalWorld ) {
UnityGI o_gi;
ResetUnityGI( o_gi);
o_gi.light = data.light;
o_gi.light.color *= data.atten;
o_gi.indirect.diffuse = ShadeSHPerPixel( normalWorld, data.ambient);
o_gi.indirect.diffuse *= occlusion;
return o_gi;
}
UnityGI UnityGlobalIllumination( in UnityGIInput data, in mediump float occlusion, in mediump vec3 normalWorld ) {
return UnityGI_Base( data, occlusion, normalWorld);
}
mediump vec3 DecodeHDR( in mediump vec4 data, in mediump vec4 decodeInstructions ) {
return ((decodeInstructions.x * data.w) * data.xyz);
}
mediump vec3 DecodeHDR_NoLinearSupportInSM2( in mediump vec4 data, in mediump vec4 decodeInstructions ) {
return DecodeHDR( data, decodeInstructions);
}
mediump vec3 Unity_GlossyEnvironment( in samplerCube tex, in mediump vec4 hdr, in Unity_GlossyEnvironmentData glossIn ) {
mediump float roughness = glossIn.roughness;
roughness = (roughness * (1.7 - (0.7 * roughness)));
mediump float mip = (roughness * 6.0);
mediump vec4 rgbm = xll_texCUBElod( tex, vec4( glossIn.reflUVW, mip));
return DecodeHDR_NoLinearSupportInSM2( rgbm, hdr);
}
mediump vec3 UnityGI_IndirectSpecular( in UnityGIInput data, in mediump float occlusion, in mediump vec3 normalWorld, in Unity_GlossyEnvironmentData glossIn ) {
mediump vec3 specular;
mediump vec3 env0 = Unity_GlossyEnvironment( unity_SpecCube0, data.probeHDR[0], glossIn);
specular = env0;
return (specular * occlusion);
}
UnityGI UnityGlobalIllumination( in UnityGIInput data, in mediump float occlusion, in mediump vec3 normalWorld, in Unity_GlossyEnvironmentData glossIn ) {
UnityGI o_gi = UnityGI_Base( data, occlusion, normalWorld);
o_gi.indirect.specular = UnityGI_IndirectSpecular( data, occlusion, normalWorld, glossIn);
return o_gi;
}
UnityGI FragmentGI( in FragmentCommonData s, in mediump float occlusion, in mediump vec4 i_ambientOrLightmapUV, in mediump float atten, in UnityLight light, in bool reflections ) {
UnityGIInput d;
d.light = light;
d.worldPos = s.posWorld;
d.worldViewDir = (-s.eyeVec);
d.atten = atten;
d.ambient = i_ambientOrLightmapUV.xyz;
d.lightmapUV = vec4( 0.0);
d.boxMax[0] = unity_SpecCube0_BoxMax;
d.boxMin[0] = unity_SpecCube0_BoxMin;
d.probePosition[0] = unity_SpecCube0_ProbePosition;
d.probeHDR[0] = unity_SpecCube0_HDR;
d.boxMax[1] = unity_SpecCube1_BoxMax;
d.boxMin[1] = unity_SpecCube1_BoxMin;
d.probePosition[1] = unity_SpecCube1_ProbePosition;
d.probeHDR[1] = unity_SpecCube1_HDR;
if (reflections){
Unity_GlossyEnvironmentData g;
g.roughness = (1.0 - s.oneMinusRoughness);
g.reflUVW = reflect( s.eyeVec, s.normalWorld);
return UnityGlobalIllumination( d, occlusion, s.normalWorld, g);
}
else{
return UnityGlobalIllumination( d, occlusion, s.normalWorld);
}
}
UnityGI FragmentGI( in highp vec3 posWorld, in mediump float occlusion, in mediump vec4 i_ambientOrLightmapUV, in mediump float atten, in mediump float oneMinusRoughness, in mediump vec3 normalWorld, in mediump vec3 eyeVec, in UnityLight light, in bool reflections ) {
FragmentCommonData s = FragmentCommonData(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), 0.0, 0.0, vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), 0.0);
s.oneMinusRoughness = oneMinusRoughness;
s.normalWorld = normalWorld;
s.eyeVec = eyeVec;
s.posWorld = posWorld;
return FragmentGI( s, occlusion, i_ambientOrLightmapUV, atten, light, reflections);
}
UnityGI FragmentGI( in highp vec3 posWorld, in mediump float occlusion, in mediump vec4 i_ambientOrLightmapUV, in mediump float atten, in mediump float oneMinusRoughness, in mediump vec3 normalWorld, in mediump vec3 eyeVec, in UnityLight light ) {
return FragmentGI( posWorld, occlusion, i_ambientOrLightmapUV, atten, oneMinusRoughness, normalWorld, eyeVec, light, true);
}
mediump float Alpha( in highp vec2 uv ) {
return (texture( _MainTex, uv).w * _Color.w);
}
mediump vec3 Albedo( in highp vec4 texcoords ) {
mediump vec3 albedo = (_Color.xyz * texture( _MainTex, texcoords.xy).xyz);
return albedo;
}
mediump float OneMinusReflectivityFromMetallic( in mediump float metallic ) {
mediump float oneMinusDielectricSpec = unity_ColorSpaceDielectricSpec.w;
return (oneMinusDielectricSpec - (metallic * oneMinusDielectricSpec));
}
mediump vec3 DiffuseAndSpecularFromMetallic( in mediump vec3 albedo, in mediump float metallic, out mediump vec3 specColor, out mediump float oneMinusReflectivity ) {
specColor = mix( unity_ColorSpaceDielectricSpec.xyz, albedo, vec3( metallic));
oneMinusReflectivity = OneMinusReflectivityFromMetallic( metallic);
return (albedo * oneMinusReflectivity);
}
mediump vec2 MetallicGloss( in highp vec2 uv ) {
mediump vec2 mg;
mg = vec2( _Metallic, _Glossiness);
return mg;
}
FragmentCommonData MetallicSetup( in highp vec4 i_tex ) {
mediump vec2 metallicGloss = MetallicGloss( i_tex.xy);
mediump float metallic = metallicGloss.x;
mediump float oneMinusRoughness = metallicGloss.y;
mediump float oneMinusReflectivity;
mediump vec3 specColor;
mediump vec3 diffColor = DiffuseAndSpecularFromMetallic( Albedo( i_tex), metallic, specColor, oneMinusReflectivity);
FragmentCommonData o = FragmentCommonData(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), 0.0, 0.0, vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), 0.0);
o.diffColor = diffColor;
o.specColor = specColor;
o.oneMinusReflectivity = oneMinusReflectivity;
o.oneMinusRoughness = oneMinusRoughness;
return o;
}
mediump vec3 NormalizePerPixelNormal( in mediump vec3 n ) {
return normalize(n);
}
highp vec4 Parallax( in highp vec4 texcoords, in mediump vec3 viewDir ) {
return texcoords;
}
mediump vec3 PerPixelWorldNormal( in highp vec4 i_tex, in mediump vec4 tangentToWorld[3] ) {
mediump vec3 normalWorld = normalize(tangentToWorld[2].xyz);
return normalWorld;
}
mediump vec3 PreMultiplyAlpha( in mediump vec3 diffColor, in mediump float alpha, in mediump float oneMinusReflectivity, out mediump float outModifiedAlpha ) {
outModifiedAlpha = alpha;
return diffColor;
}
FragmentCommonData FragmentSetup( in highp vec4 i_tex, in mediump vec3 i_eyeVec, in mediump vec3 i_viewDirForParallax, in mediump vec4 tangentToWorld[3], in mediump vec3 i_posWorld ) {
i_tex = Parallax( i_tex, i_viewDirForParallax);
mediump float alpha = Alpha( i_tex.xy);
FragmentCommonData o = MetallicSetup( i_tex);
o.normalWorld = PerPixelWorldNormal( i_tex, tangentToWorld);
o.eyeVec = NormalizePerPixelNormal( i_eyeVec);
o.posWorld = i_posWorld;
o.diffColor = PreMultiplyAlpha( o.diffColor, alpha, o.oneMinusReflectivity, o.alpha);
return o;
}
mediump float LambertTerm( in mediump vec3 normal, in mediump vec3 lightDir ) {
return DotClamped( normal, lightDir);
}
UnityLight MainLight( in mediump vec3 normalWorld ) {
UnityLight l;
l.color = _LightColor0.xyz;
l.dir = _WorldSpaceLightPos0.xyz;
l.ndotl = LambertTerm( normalWorld, l.dir);
return l;
}
mediump float LerpOneTo( in mediump float b, in mediump float t ) {
mediump float oneMinusT = (1.0 - t);
return (oneMinusT + (b * t));
}
mediump float Occlusion( in highp vec2 uv ) {
mediump float occ = texture( _OcclusionMap, uv).y;
return LerpOneTo( occ, _OcclusionStrength);
}
mediump vec4 OutputForward( in mediump vec4 xlat_varoutput, in mediump float alphaFromSurface ) {
xlat_varoutput.w = 1.0;
return xlat_varoutput;
}
lowp float unitySampleShadow( in mediump vec4 shadowCoord ) {
lowp float shadow = xll_shadow2D( _ShadowMapTexture, shadowCoord.xyz.xyz);
shadow = (_LightShadowData.x + (shadow * (1.0 - _LightShadowData.x)));
return shadow;
}
mediump vec4 fragForwardBase_VC( in VertexOutputForwardBase_VC i ) {
FragmentCommonData s = FragmentSetup( i.tex, i.eyeVec, vec3( 0.0, 0.0, 0.0), i.tangentToWorldAndParallax, vec3( 0.0, 0.0, 0.0));
UnityLight mainLight = MainLight( s.normalWorld);
mediump float atten = unitySampleShadow( i._ShadowCoord);
mediump float occlusion = Occlusion( i.tex.xy);
UnityGI gi = FragmentGI( s.posWorld, occlusion, i.ambientOrLightmapUV, atten, s.oneMinusRoughness, s.normalWorld, s.eyeVec, mainLight);
mediump vec4 c = BRDF2_Unity_PBS( s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, (-s.eyeVec), gi.light, gi.indirect);
c *= i.color;
c.xyz += BRDF_Unity_Indirect( s.diffColor, s.specColor, s.oneMinusReflectivity, s.oneMinusRoughness, s.normalWorld, (-s.eyeVec), occlusion, gi);
c.xyz += Emission( i.tex.xy);
return OutputForward( c, (s.alpha * i.color.w));
}
in highp vec4 xlv_TEXCOORD0;
in mediump vec3 xlv_TEXCOORD1;
in mediump vec4 xlv_TEXCOORD2;
in mediump vec4 xlv_TEXCOORD2_1;
in mediump vec4 xlv_TEXCOORD2_2;
in mediump vec4 xlv_TEXCOORD5;
in mediump vec4 xlv_TEXCOORD6;
in lowp vec4 xlv_COLOR;
out lowp vec4 FragData [1];
void main() {
mediump vec4 xl_retval;
VertexOutputForwardBase_VC xlt_i;
xlt_i.pos = vec4(0.0);
xlt_i.tex = vec4(xlv_TEXCOORD0);
xlt_i.eyeVec = vec3(xlv_TEXCOORD1);
xlt_i.tangentToWorldAndParallax[0] = vec4(xlv_TEXCOORD2);
xlt_i.tangentToWorldAndParallax[1] = vec4(xlv_TEXCOORD2_1);
xlt_i.tangentToWorldAndParallax[2] = vec4(xlv_TEXCOORD2_2);
xlt_i.ambientOrLightmapUV = vec4(xlv_TEXCOORD5);
xlt_i._ShadowCoord = vec4(xlv_TEXCOORD6);
xlt_i.color = vec4(xlv_COLOR);
xl_retval = fragForwardBase_VC( xlt_i);
FragData[0] = vec4(xl_retval);
}

View File

@ -0,0 +1,187 @@
#version 300 es
struct FragmentCommonData {
mediump vec3 diffColor;
mediump vec3 specColor;
mediump float oneMinusReflectivity;
mediump float oneMinusRoughness;
mediump vec3 normalWorld;
mediump vec3 eyeVec;
mediump vec3 posWorld;
mediump float alpha;
};
uniform mediump vec4 _WorldSpaceLightPos0;
uniform mediump vec4 unity_SHAr;
uniform mediump vec4 unity_SHAg;
uniform mediump vec4 unity_SHAb;
uniform mediump vec4 _LightShadowData;
uniform lowp samplerCube unity_SpecCube0;
uniform mediump vec4 unity_SpecCube0_HDR;
uniform mediump vec4 unity_ColorSpaceDielectricSpec;
uniform lowp vec4 _LightColor0;
uniform mediump vec4 _Color;
uniform sampler2D _MainTex;
uniform mediump float _Metallic;
uniform mediump float _Glossiness;
uniform sampler2D _OcclusionMap;
uniform mediump float _OcclusionStrength;
uniform lowp sampler2DShadow _ShadowMapTexture;
in highp vec4 xlv_TEXCOORD0;
in mediump vec3 xlv_TEXCOORD1;
in mediump vec4 xlv_TEXCOORD2_2;
in mediump vec4 xlv_TEXCOORD5;
in mediump vec4 xlv_TEXCOORD6;
in lowp vec4 xlv_COLOR;
out lowp vec4 FragData[1];
void main ()
{
mediump vec4 c_1;
mediump float atten_2;
lowp vec4 tmpvar_3;
tmpvar_3 = texture (_MainTex, xlv_TEXCOORD0.xy);
mediump vec2 tmpvar_4;
tmpvar_4.x = _Metallic;
tmpvar_4.y = _Glossiness;
mediump vec3 tmpvar_5;
tmpvar_5 = (_Color.xyz * tmpvar_3.xyz);
mediump vec3 tmpvar_6;
mediump vec3 tmpvar_7;
tmpvar_7 = mix (unity_ColorSpaceDielectricSpec.xyz, tmpvar_5, vec3(_Metallic));
mediump float tmpvar_8;
tmpvar_8 = (unity_ColorSpaceDielectricSpec.w - (_Metallic * unity_ColorSpaceDielectricSpec.w));
tmpvar_6 = (tmpvar_5 * tmpvar_8);
mediump vec3 tmpvar_9;
tmpvar_9 = normalize(xlv_TEXCOORD2_2.xyz);
mediump vec3 tmpvar_10;
tmpvar_10 = normalize(xlv_TEXCOORD1);
mediump vec3 tmpvar_11;
tmpvar_11 = _LightColor0.xyz;
lowp float shadow_12;
mediump float tmpvar_13;
tmpvar_13 = texture (_ShadowMapTexture, xlv_TEXCOORD6.xyz);
lowp float tmpvar_14;
tmpvar_14 = tmpvar_13;
shadow_12 = (_LightShadowData.x + (tmpvar_14 * (1.0 - _LightShadowData.x)));
atten_2 = shadow_12;
mediump float occ_15;
lowp float tmpvar_16;
tmpvar_16 = texture (_OcclusionMap, xlv_TEXCOORD0.xy).y;
occ_15 = tmpvar_16;
mediump float tmpvar_17;
tmpvar_17 = ((1.0 - _OcclusionStrength) + (occ_15 * _OcclusionStrength));
FragmentCommonData s_18;
s_18 = FragmentCommonData(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), 0.0, 0.0, vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), 0.0);
s_18.oneMinusRoughness = tmpvar_4.y;
s_18.normalWorld = tmpvar_9;
s_18.eyeVec = tmpvar_10;
s_18.posWorld = vec3(0.0, 0.0, 0.0);
mediump vec3 tmpvar_19;
mediump vec3 tmpvar_20;
tmpvar_19 = s_18.normalWorld;
tmpvar_20 = s_18.eyeVec;
highp vec4 tmpvar_21;
tmpvar_21 = unity_SpecCube0_HDR;
mediump float tmpvar_22;
tmpvar_22 = (1.0 - s_18.oneMinusRoughness);
mediump vec3 tmpvar_23;
tmpvar_23 = (tmpvar_20 - (2.0 * (
dot (tmpvar_19, tmpvar_20)
* tmpvar_19)));
mediump vec4 tmpvar_24;
tmpvar_24.w = 1.0;
tmpvar_24.xyz = tmpvar_19;
mediump vec3 x_25;
x_25.x = dot (unity_SHAr, tmpvar_24);
x_25.y = dot (unity_SHAg, tmpvar_24);
x_25.z = dot (unity_SHAb, tmpvar_24);
mediump vec4 hdr_26;
hdr_26 = tmpvar_21;
mediump vec4 tmpvar_27;
tmpvar_27.xyz = tmpvar_23;
tmpvar_27.w = ((tmpvar_22 * (1.7 -
(0.7 * tmpvar_22)
)) * 6.0);
lowp vec4 tmpvar_28;
tmpvar_28 = textureLod (unity_SpecCube0, tmpvar_23, tmpvar_27.w);
mediump vec4 tmpvar_29;
tmpvar_29 = tmpvar_28;
mediump vec3 viewDir_30;
viewDir_30 = -(tmpvar_10);
mediump vec3 tmpvar_31;
mediump vec3 inVec_32;
inVec_32 = (_WorldSpaceLightPos0.xyz + viewDir_30);
tmpvar_31 = (inVec_32 * inversesqrt(max (0.001,
dot (inVec_32, inVec_32)
)));
mediump float tmpvar_33;
tmpvar_33 = max (0.0, dot (_WorldSpaceLightPos0.xyz, tmpvar_31));
mediump float tmpvar_34;
tmpvar_34 = (1.0 - _Glossiness);
mediump float tmpvar_35;
tmpvar_35 = max (0.0001, (tmpvar_34 * tmpvar_34));
mediump float tmpvar_36;
tmpvar_36 = max (((2.0 /
(tmpvar_35 * tmpvar_35)
) - 2.0), 0.0001);
mediump float x_37;
x_37 = (1.0 - max (0.0, dot (tmpvar_9, viewDir_30)));
mediump vec4 tmpvar_38;
tmpvar_38.w = 1.0;
tmpvar_38.xyz = (((
((tmpvar_6 + (sqrt(
max (0.0001, (((tmpvar_36 + 1.0) * pow (
max (0.0, dot (tmpvar_9, tmpvar_31))
, tmpvar_36)) / ((
(8.0 * (((tmpvar_33 * tmpvar_33) * _Glossiness) + (tmpvar_34 * tmpvar_34)))
* tmpvar_33) + 0.0001)))
) * tmpvar_7)) * (tmpvar_11 * atten_2))
*
max (0.0, dot (tmpvar_9, _WorldSpaceLightPos0.xyz))
) + (
(max (((1.055 *
pow (max (vec3(0.0, 0.0, 0.0), (xlv_TEXCOORD5.xyz + x_25)), vec3(0.4166667, 0.4166667, 0.4166667))
) - 0.055), vec3(0.0, 0.0, 0.0)) * tmpvar_17)
* tmpvar_6)) + ((
(1.0 - ((tmpvar_34 * tmpvar_34) * (tmpvar_34 * 0.28)))
*
(((hdr_26.x * tmpvar_29.w) * tmpvar_29.xyz) * tmpvar_17)
) * mix (tmpvar_7, vec3(
clamp ((_Glossiness + (1.0 - tmpvar_8)), 0.0, 1.0)
), vec3(
((x_37 * x_37) * (x_37 * x_37))
))));
c_1 = (tmpvar_38 * xlv_COLOR);
c_1.xyz = c_1.xyz;
c_1.xyz = c_1.xyz;
mediump vec4 xlat_varoutput_39;
xlat_varoutput_39.xyz = c_1.xyz;
xlat_varoutput_39.w = 1.0;
FragData[0] = xlat_varoutput_39;
}
// stats: 97 alu 4 tex 0 flow
// inputs: 6
// #0: xlv_TEXCOORD0 (high float) 4x1 [-1]
// #1: xlv_TEXCOORD1 (medium float) 3x1 [-1]
// #2: xlv_TEXCOORD2_2 (medium float) 4x1 [-1]
// #3: xlv_TEXCOORD5 (medium float) 4x1 [-1]
// #4: xlv_TEXCOORD6 (medium float) 4x1 [-1]
// #5: xlv_COLOR (low float) 4x1 [-1]
// uniforms: 12 (total size: 0)
// #0: _WorldSpaceLightPos0 (medium float) 4x1 [-1]
// #1: unity_SHAr (medium float) 4x1 [-1]
// #2: unity_SHAg (medium float) 4x1 [-1]
// #3: unity_SHAb (medium float) 4x1 [-1]
// #4: _LightShadowData (medium float) 4x1 [-1]
// #5: unity_SpecCube0_HDR (medium float) 4x1 [-1]
// #6: unity_ColorSpaceDielectricSpec (medium float) 4x1 [-1]
// #7: _LightColor0 (low float) 4x1 [-1]
// #8: _Color (medium float) 4x1 [-1]
// #9: _Metallic (medium float) 1x1 [-1]
// #10: _Glossiness (medium float) 1x1 [-1]
// #11: _OcclusionStrength (medium float) 1x1 [-1]
// textures: 4
// #0: unity_SpecCube0 (low cube) 0x0 [-1]
// #1: _MainTex (low 2d) 0x0 [-1]
// #2: _OcclusionMap (low 2d) 0x0 [-1]
// #3: _ShadowMapTexture (low 2dshadow) 0x0 [-1]

View File

@ -0,0 +1,199 @@
#include <metal_stdlib>
#pragma clang diagnostic ignored "-Wparentheses-equality"
using namespace metal;
constexpr sampler _mtl_xl_shadow_sampler(address::clamp_to_edge, filter::linear, compare_func::less);
struct FragmentCommonData {
half3 diffColor;
half3 specColor;
half oneMinusReflectivity;
half oneMinusRoughness;
half3 normalWorld;
half3 eyeVec;
half3 posWorld;
half alpha;
};
constant FragmentCommonData _xlat_mtl_const1 = {float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), 0.0};
struct xlatMtlShaderInput {
float4 xlv_TEXCOORD0;
half3 xlv_TEXCOORD1;
half4 xlv_TEXCOORD2_2;
half4 xlv_TEXCOORD5;
half4 xlv_TEXCOORD6;
half4 xlv_COLOR;
};
struct xlatMtlShaderOutput {
half4 FragData_0 [[color(0)]];
};
struct xlatMtlShaderUniform {
half4 _WorldSpaceLightPos0;
half4 unity_SHAr;
half4 unity_SHAg;
half4 unity_SHAb;
half4 _LightShadowData;
half4 unity_SpecCube0_HDR;
half4 unity_ColorSpaceDielectricSpec;
half4 _LightColor0;
half4 _Color;
half _Metallic;
half _Glossiness;
half _OcclusionStrength;
};
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
, texturecube<half> unity_SpecCube0 [[texture(0)]], sampler _mtlsmp_unity_SpecCube0 [[sampler(0)]]
, texture2d<half> _MainTex [[texture(1)]], sampler _mtlsmp__MainTex [[sampler(1)]]
, texture2d<half> _OcclusionMap [[texture(2)]], sampler _mtlsmp__OcclusionMap [[sampler(2)]]
, depth2d<float> _ShadowMapTexture [[texture(3)]], sampler _mtlsmp__ShadowMapTexture [[sampler(3)]])
{
xlatMtlShaderOutput _mtl_o;
half4 c_1;
half atten_2;
half4 tmpvar_3;
tmpvar_3 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0.xy));
half2 tmpvar_4;
tmpvar_4.x = _mtl_u._Metallic;
tmpvar_4.y = _mtl_u._Glossiness;
half3 tmpvar_5;
tmpvar_5 = (_mtl_u._Color.xyz * tmpvar_3.xyz);
half3 tmpvar_6;
half3 tmpvar_7;
tmpvar_7 = mix (_mtl_u.unity_ColorSpaceDielectricSpec.xyz, tmpvar_5, half3(_mtl_u._Metallic));
half tmpvar_8;
tmpvar_8 = (_mtl_u.unity_ColorSpaceDielectricSpec.w - (_mtl_u._Metallic * _mtl_u.unity_ColorSpaceDielectricSpec.w));
tmpvar_6 = (tmpvar_5 * tmpvar_8);
half3 tmpvar_9;
tmpvar_9 = normalize(_mtl_i.xlv_TEXCOORD2_2.xyz);
half3 tmpvar_10;
tmpvar_10 = normalize(_mtl_i.xlv_TEXCOORD1);
half3 tmpvar_11;
tmpvar_11 = _mtl_u._LightColor0.xyz;
half shadow_12;
half tmpvar_13;
tmpvar_13 = _ShadowMapTexture.sample_compare(_mtl_xl_shadow_sampler, (float2)(_mtl_i.xlv_TEXCOORD6.xyz).xy, (float)(_mtl_i.xlv_TEXCOORD6.xyz).z);
half tmpvar_14;
tmpvar_14 = tmpvar_13;
shadow_12 = (_mtl_u._LightShadowData.x + (tmpvar_14 * ((half)1.0 - _mtl_u._LightShadowData.x)));
atten_2 = shadow_12;
half occ_15;
half tmpvar_16;
tmpvar_16 = _OcclusionMap.sample(_mtlsmp__OcclusionMap, (float2)(_mtl_i.xlv_TEXCOORD0.xy)).y;
occ_15 = tmpvar_16;
half tmpvar_17;
tmpvar_17 = (((half)1.0 - _mtl_u._OcclusionStrength) + (occ_15 * _mtl_u._OcclusionStrength));
FragmentCommonData s_18;
s_18 = _xlat_mtl_const1;
s_18.oneMinusRoughness = tmpvar_4.y;
s_18.normalWorld = tmpvar_9;
s_18.eyeVec = tmpvar_10;
s_18.posWorld = half3(float3(0.0, 0.0, 0.0));
half3 tmpvar_19;
half3 tmpvar_20;
tmpvar_19 = s_18.normalWorld;
tmpvar_20 = s_18.eyeVec;
float4 tmpvar_21;
tmpvar_21 = float4(_mtl_u.unity_SpecCube0_HDR);
half tmpvar_22;
tmpvar_22 = ((half)1.0 - s_18.oneMinusRoughness);
half3 tmpvar_23;
tmpvar_23 = (tmpvar_20 - ((half)2.0 * (
dot (tmpvar_19, tmpvar_20)
* tmpvar_19)));
half4 tmpvar_24;
tmpvar_24.w = half(1.0);
tmpvar_24.xyz = tmpvar_19;
half3 x_25;
x_25.x = dot (_mtl_u.unity_SHAr, tmpvar_24);
x_25.y = dot (_mtl_u.unity_SHAg, tmpvar_24);
x_25.z = dot (_mtl_u.unity_SHAb, tmpvar_24);
half4 hdr_26;
hdr_26 = half4(tmpvar_21);
half4 tmpvar_27;
tmpvar_27.xyz = tmpvar_23;
tmpvar_27.w = ((tmpvar_22 * ((half)1.7 -
((half)0.7 * tmpvar_22)
)) * (half)6.0);
half4 tmpvar_28;
tmpvar_28 = unity_SpecCube0.sample(_mtlsmp_unity_SpecCube0, (float3)(tmpvar_23), level(tmpvar_27.w));
half4 tmpvar_29;
tmpvar_29 = tmpvar_28;
half3 viewDir_30;
viewDir_30 = -(tmpvar_10);
half3 tmpvar_31;
half3 inVec_32;
inVec_32 = (_mtl_u._WorldSpaceLightPos0.xyz + viewDir_30);
tmpvar_31 = (inVec_32 * rsqrt(max ((half)0.001,
dot (inVec_32, inVec_32)
)));
half tmpvar_33;
tmpvar_33 = max ((half)0.0, dot (_mtl_u._WorldSpaceLightPos0.xyz, tmpvar_31));
half tmpvar_34;
tmpvar_34 = ((half)1.0 - _mtl_u._Glossiness);
half tmpvar_35;
tmpvar_35 = max ((half)0.0001, (tmpvar_34 * tmpvar_34));
half tmpvar_36;
tmpvar_36 = max ((((half)2.0 /
(tmpvar_35 * tmpvar_35)
) - (half)2.0), (half)0.0001);
half x_37;
x_37 = ((half)1.0 - max ((half)0.0, dot (tmpvar_9, viewDir_30)));
half4 tmpvar_38;
tmpvar_38.w = half(1.0);
tmpvar_38.xyz = (((
((tmpvar_6 + (sqrt(
max ((half)0.0001, (((tmpvar_36 + (half)1.0) * pow (
max ((half)0.0, dot (tmpvar_9, tmpvar_31))
, tmpvar_36)) / ((
((half)8.0 * (((tmpvar_33 * tmpvar_33) * _mtl_u._Glossiness) + (tmpvar_34 * tmpvar_34)))
* tmpvar_33) + (half)0.0001)))
) * tmpvar_7)) * (tmpvar_11 * atten_2))
*
max ((half)0.0, dot (tmpvar_9, _mtl_u._WorldSpaceLightPos0.xyz))
) + (
(max ((((half)1.055 *
pow (max ((half3)float3(0.0, 0.0, 0.0), (_mtl_i.xlv_TEXCOORD5.xyz + x_25)), (half3)float3(0.4166667, 0.4166667, 0.4166667))
) - (half)0.055), (half3)float3(0.0, 0.0, 0.0)) * tmpvar_17)
* tmpvar_6)) + ((
((half)1.0 - ((tmpvar_34 * tmpvar_34) * (tmpvar_34 * (half)0.28)))
*
(((hdr_26.x * tmpvar_29.w) * tmpvar_29.xyz) * tmpvar_17)
) * mix (tmpvar_7, half3(
clamp ((_mtl_u._Glossiness + ((half)1.0 - tmpvar_8)), (half)0.0, (half)1.0)
), half3(
((x_37 * x_37) * (x_37 * x_37))
))));
c_1 = (tmpvar_38 * _mtl_i.xlv_COLOR);
c_1.xyz = c_1.xyz;
c_1.xyz = c_1.xyz;
half4 xlat_varoutput_39;
xlat_varoutput_39.xyz = c_1.xyz;
xlat_varoutput_39.w = half(1.0);
_mtl_o.FragData_0 = xlat_varoutput_39;
return _mtl_o;
}
// stats: 97 alu 4 tex 0 flow
// inputs: 6
// #0: xlv_TEXCOORD0 (high float) 4x1 [-1]
// #1: xlv_TEXCOORD1 (medium float) 3x1 [-1]
// #2: xlv_TEXCOORD2_2 (medium float) 4x1 [-1]
// #3: xlv_TEXCOORD5 (medium float) 4x1 [-1]
// #4: xlv_TEXCOORD6 (medium float) 4x1 [-1]
// #5: xlv_COLOR (low float) 4x1 [-1]
// uniforms: 12 (total size: 78)
// #0: _WorldSpaceLightPos0 (medium float) 4x1 [-1] loc 0
// #1: unity_SHAr (medium float) 4x1 [-1] loc 8
// #2: unity_SHAg (medium float) 4x1 [-1] loc 16
// #3: unity_SHAb (medium float) 4x1 [-1] loc 24
// #4: _LightShadowData (medium float) 4x1 [-1] loc 32
// #5: unity_SpecCube0_HDR (medium float) 4x1 [-1] loc 40
// #6: unity_ColorSpaceDielectricSpec (medium float) 4x1 [-1] loc 48
// #7: _LightColor0 (low float) 4x1 [-1] loc 56
// #8: _Color (medium float) 4x1 [-1] loc 64
// #9: _Metallic (medium float) 1x1 [-1] loc 72
// #10: _Glossiness (medium float) 1x1 [-1] loc 74
// #11: _OcclusionStrength (medium float) 1x1 [-1] loc 76
// textures: 4
// #0: unity_SpecCube0 (low cube) 0x0 [-1] loc 0
// #1: _MainTex (low 2d) 0x0 [-1] loc 1
// #2: _OcclusionMap (low 2d) 0x0 [-1] loc 2
// #3: _ShadowMapTexture (low 2dshadow) 0x0 [-1] loc 3

File diff suppressed because it is too large Load Diff

View File

@ -62,11 +62,11 @@ struct ImGuiSizeConstraintCallbackData;// Structure used to constraint window si
struct ImGuiListClipper; // Helper to manually clip large list of items
struct ImGuiContext; // ImGui context (opaque)
// Enumerations (declared as int for compatibility and to not pollute the top of this file)
typedef unsigned int ImU32;
// Typedefs and Enumerations (declared as int for compatibility and to not pollute the top of this file)
typedef unsigned int ImU32; // 32-bit unsigned integer (typically used to store packed colors)
typedef unsigned int ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
typedef unsigned short ImWchar; // character for keyboard input/display
typedef void* ImTextureID; // user data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
typedef ImU32 ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
typedef int ImGuiCol; // a color identifier for styling // enum ImGuiCol_
typedef int ImGuiStyleVar; // a variable identifier for styling // enum ImGuiStyleVar_
typedef int ImGuiKey; // a key identifier (ImGui-side enum) // enum ImGuiKey_
@ -352,7 +352,7 @@ namespace ImGui
IMGUI_API void Value(const char* prefix, unsigned int v);
IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
IMGUI_API void ValueColor(const char* prefix, const ImVec4& v);
IMGUI_API void ValueColor(const char* prefix, unsigned int v);
IMGUI_API void ValueColor(const char* prefix, ImU32 v);
// Tooltips
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
@ -409,7 +409,8 @@ namespace ImGui
IMGUI_API bool IsRootWindowFocused(); // is current root window focused (root = top-most parent of a child, otherwise self)
IMGUI_API bool IsRootWindowOrAnyChildFocused(); // is current root window or any of its child (including current window) focused
IMGUI_API bool IsRootWindowOrAnyChildHovered(); // is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup)
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle of given size starting from cursor pos is visible (not clipped). to perform coarse clipping on user's side (as an optimization)
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
IMGUI_API bool IsPosHoveringAnyWindow(const ImVec2& pos); // is given position hovering any active imgui window
IMGUI_API float GetTime();
IMGUI_API int GetFrameCount();
@ -467,15 +468,9 @@ namespace ImGui
static inline bool CollapsingHeader(const char* label, const char* str_id, bool framed = true, bool default_open = false) { (void)str_id; (void)framed; ImGuiTreeNodeFlags default_open_flags = 1<<5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
static inline float GetWindowFontSize() { return GetFontSize(); } // OBSOLETE 1.48+
static inline void OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpen(open, 0); } // OBSOLETE 1.34+
static inline bool GetWindowIsFocused() { return ImGui::IsWindowFocused(); } // OBSOLETE 1.36+
static inline bool GetWindowCollapsed() { return ImGui::IsWindowCollapsed(); } // OBSOLETE 1.39+
static inline ImVec2 GetItemBoxMin() { return GetItemRectMin(); } // OBSOLETE 1.36+
static inline ImVec2 GetItemBoxMax() { return GetItemRectMax(); } // OBSOLETE 1.36+
static inline bool IsClipped(const ImVec2& size) { return !IsRectVisible(size); } // OBSOLETE 1.38+
static inline bool IsRectClipped(const ImVec2& size) { return !IsRectVisible(size); } // OBSOLETE 1.39+
static inline bool IsMouseHoveringBox(const ImVec2& rect_min, const ImVec2& rect_max) { return IsMouseHoveringRect(rect_min, rect_max); } // OBSOLETE 1.36+
static inline void SetScrollPosHere() { SetScrollHere(); } // OBSOLETE 1.42+
static inline bool GetWindowCollapsed() { return ImGui::IsWindowCollapsed(); } // OBSOLETE 1.39+
static inline bool IsRectClipped(const ImVec2& size) { return !IsRectVisible(size); } // OBSOLETE 1.39+
#endif
} // namespace ImGui
@ -694,9 +689,9 @@ enum ImGuiMouseCursor_
enum ImGuiSetCond_
{
ImGuiSetCond_Always = 1 << 0, // Set the variable
ImGuiSetCond_Once = 1 << 1, // Only set the variable on the first call per runtime session
ImGuiSetCond_FirstUseEver = 1 << 2, // Only set the variable if the window doesn't exist in the .ini file
ImGuiSetCond_Appearing = 1 << 3 // Only set the variable if the window is appearing after being inactive (or the first time)
ImGuiSetCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed)
ImGuiSetCond_FirstUseEver = 1 << 2, // Set the variable if the window has no saved data (if doesn't exist in the .ini file)
ImGuiSetCond_Appearing = 1 << 3 // Set the variable if the window is appearing after being hidden/inactive (or the first time)
};
struct ImGuiStyle
@ -758,10 +753,7 @@ struct ImGuiIO
ImVec2 DisplayVisibleMax; // <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
// Advanced/subtle behaviors
bool WordMovementUsesAltKey; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl
bool ShortcutsUseSuperKey; // = defined(__APPLE__) // OS X style: Shortcuts using Cmd/Super instead of Ctrl
bool DoubleClickSelectsWord; // = defined(__APPLE__) // OS X style: Double click selects by word instead of selecting whole text
bool MultiSelectUsesSuperKey; // = defined(__APPLE__) // OS X style: Multi-selection in lists uses Cmd/Super instead of Ctrl [unused yet]
bool OSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl
//------------------------------------------------------------------
// User Functions
@ -888,6 +880,7 @@ public:
if (new_capacity <= Capacity) return;
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
memset(&new_data[Size], 0, (size_t)(new_capacity - Size) * sizeof(value_type)); // BK - clear garbage so that 0 initialized ImString works properly.
if (Data)
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
ImGui::MemFree(Data);
Data = new_data;
@ -1272,7 +1265,7 @@ struct ImFontConfig
int FontNo; // 0 // Index of font within TTF file
float SizePixels; // // Size in pixels for rasterizer
int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
bool PixelSnapH; // false // Align every character to pixel boundary (if enabled, set OversampleH/V to 1)
bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs
const ImWchar* GlyphRanges; // // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
@ -1325,6 +1318,7 @@ struct ImFontAtlas
IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs
IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
IMGUI_API const ImWchar* GetGlyphRangesThai(); // Default + Thai characters
// Members
// (Access texture data via GetTexData*() calls which will setup a default font for you.)

View File

@ -1020,24 +1020,24 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::Text("Hello\nWorld"); ImGui::SameLine();
ImGui::Text("One\nTwo\nThree");
ImGui::Button("HOP"); ImGui::SameLine();
ImGui::Button("HOP##1"); ImGui::SameLine();
ImGui::Text("Banana"); ImGui::SameLine();
ImGui::Text("Hello\nWorld"); ImGui::SameLine();
ImGui::Text("Banana");
ImGui::Button("HOP"); ImGui::SameLine();
ImGui::Button("HOP##2"); ImGui::SameLine();
ImGui::Text("Hello\nWorld"); ImGui::SameLine();
ImGui::Text("Banana");
ImGui::Button("TEST"); ImGui::SameLine();
ImGui::Button("TEST##1"); ImGui::SameLine();
ImGui::Text("TEST"); ImGui::SameLine();
ImGui::SmallButton("TEST");
ImGui::SmallButton("TEST##2");
ImGui::AlignFirstTextHeightToWidgets(); // If your line starts with text, call this to align it to upcoming widgets.
ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
ImGui::Button("Widget"); ImGui::SameLine();
ImGui::Button("Widget##1"); ImGui::SameLine();
ImGui::Text("Widget"); ImGui::SameLine();
ImGui::SmallButton("Widget");
ImGui::SmallButton("Widget##2");
// Tree
const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
@ -1415,9 +1415,9 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::InputFloat("blue", &bar, 0.05f, 0, 3);
ImGui::NextColumn();
if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
if (ImGui::CollapsingHeader("Category B")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
if (ImGui::CollapsingHeader("Category C")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
ImGui::Columns(1);
ImGui::Separator();
ImGui::TreePop();
@ -1873,9 +1873,9 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
"Custom: Fixed Steps (100)",
};
ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200,200)); } ImGui::SameLine();
if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500,500)); } ImGui::SameLine();
if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800,200)); }
if (ImGui::Button("200x200")) ImGui::SetWindowSize(ImVec2(200,200)); ImGui::SameLine();
if (ImGui::Button("500x500")) ImGui::SetWindowSize(ImVec2(500,500)); ImGui::SameLine();
if (ImGui::Button("800x200")) ImGui::SetWindowSize(ImVec2(800,200));
for (int i = 0; i < 10; i++)
ImGui::Text("Hello, sailor! Making this line long enough for the example.");
}
@ -2088,8 +2088,8 @@ struct ExampleAppConsole
// TODO: display items starting from the bottom
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
if (ImGui::SmallButton("Add Dummy Error")) AddLog("[error] something went wrong"); ImGui::SameLine();
if (ImGui::SmallButton("Clear")) ClearLog(); ImGui::SameLine();
if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
@ -2143,7 +2143,7 @@ struct ExampleAppConsole
if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_CallbackHistory, &TextEditCallbackStub, (void*)this))
{
char* input_end = InputBuf+strlen(InputBuf);
while (input_end > InputBuf && input_end[-1] == ' ') { input_end--; } *input_end = 0;
while (input_end > InputBuf && input_end[-1] == ' ') input_end--; *input_end = 0;
if (InputBuf[0])
ExecCommand(InputBuf);
strcpy(InputBuf, "");
@ -2184,7 +2184,8 @@ struct ExampleAppConsole
}
else if (Stricmp(command_line, "HISTORY") == 0)
{
for (int i = History.Size >= 10 ? History.Size - 10 : 0; i < History.Size; i++)
int first = History.Size - 10;
for (int i = first > 0 ? first : 0; i < History.Size; i++)
AddLog("%3d: %s\n", i, History[i]);
}
else

View File

@ -19,10 +19,10 @@
#include <stdio.h> // vsnprintf, sscanf, printf
#if !defined(alloca)
#if defined(_WIN32)
#ifdef _WIN32
#include <malloc.h> // alloca
#elif defined(__FreeBSD__) || defined(__DragonFly__)
#include <stdlib.h> // alloca
#elif (defined(__FreeBSD__) || defined(FreeBSD_kernel) || defined(__DragonFly__)) && !defined(__GLIBC__)
#include <stdlib.h> // alloca. FreeBSD uses stdlib.h unless GLIBC
#else
#include <alloca.h> // alloca
#endif
@ -199,7 +199,7 @@ void ImDrawList::UpdateClipRect()
// Try to merge with previous command if it matches, else use current command
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
if (prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL)
if (curr_cmd->ElemCount == 0 && prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL)
CmdBuffer.pop_back();
else
curr_cmd->ClipRect = curr_clip_rect;
@ -1654,6 +1654,17 @@ const ImWchar* ImFontAtlas::GetGlyphRangesCyrillic()
return &ranges[0];
}
const ImWchar* ImFontAtlas::GetGlyphRangesThai()
{
static const ImWchar ranges[] =
{
0x0020, 0x00FF, // Basic Latin
0x0E00, 0x0E7F, // Thai
0,
};
return &ranges[0];
}
//-----------------------------------------------------------------------------
// ImFont
//-----------------------------------------------------------------------------

View File

@ -312,7 +312,7 @@ struct IMGUI_API ImGuiTextEditState
struct ImGuiIniData
{
char* Name;
ImGuiID ID;
ImGuiID Id;
ImVec2 Pos;
ImVec2 Size;
bool Collapsed;
@ -331,13 +331,13 @@ struct ImGuiMouseCursorData
// Storage for current popup stack
struct ImGuiPopupRef
{
ImGuiID PopupID; // Set on OpenPopup()
ImGuiID PopupId; // Set on OpenPopup()
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
ImGuiWindow* ParentWindow; // Set on OpenPopup()
ImGuiID ParentMenuSet; // Set on OpenPopup()
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupID = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
};
// Main state for ImGui
@ -481,7 +481,7 @@ struct ImGuiContext
ScalarAsInputTextId = 0;
DragCurrentValue = 0.0f;
DragLastMouseDelta = ImVec2(0.0f, 0.0f);
DragSpeedDefaultRatio = 0.01f;
DragSpeedDefaultRatio = 1.0f / 100.0f;
DragSpeedScaleSlow = 0.01f;
DragSpeedScaleFast = 10.0f;
ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
@ -522,7 +522,7 @@ struct IMGUI_API ImGuiDrawContext
float PrevLineTextBaseOffset;
float LogLinePosY;
int TreeDepth;
ImGuiID LastItemID;
ImGuiID LastItemId;
ImRect LastItemRect;
bool LastItemHoveredAndUsable; // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
bool LastItemHoveredRect; // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
@ -546,6 +546,7 @@ struct IMGUI_API ImGuiDrawContext
int StackSizesBackup[6]; // Store size of various stacks for asserting
float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
float GroupOffsetX;
float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
int ColumnsCurrent;
int ColumnsCount;
@ -555,7 +556,7 @@ struct IMGUI_API ImGuiDrawContext
float ColumnsCellMinY;
float ColumnsCellMaxY;
bool ColumnsShowBorders;
ImGuiID ColumnsSetID;
ImGuiID ColumnsSetId;
ImVector<ImGuiColumnData> ColumnsData;
ImGuiDrawContext()
@ -565,7 +566,7 @@ struct IMGUI_API ImGuiDrawContext
CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
LogLinePosY = -1.0f;
TreeDepth = 0;
LastItemID = 0;
LastItemId = 0;
LastItemRect = ImRect(0.0f,0.0f,0.0f,0.0f);
LastItemHoveredAndUsable = LastItemHoveredRect = false;
MenuBarAppending = false;
@ -587,7 +588,7 @@ struct IMGUI_API ImGuiDrawContext
ColumnsStartPosY = 0.0f;
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
ColumnsShowBorders = true;
ColumnsSetID = 0;
ColumnsSetId = 0;
}
};
@ -606,7 +607,7 @@ struct IMGUI_API ImGuiWindow
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
ImGuiID MoveID; // == window->GetID("#MOVE")
ImGuiID MoveId; // == window->GetID("#MOVE")
ImVec2 Scroll;
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
@ -619,7 +620,7 @@ struct IMGUI_API ImGuiWindow
bool Collapsed; // Set when collapsing window to become only title-bar
bool SkipItems; // == Visible && !Collapsed
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
ImGuiID PopupID; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
int AutoFitFramesX, AutoFitFramesY;
bool AutoFitOnlyGrows;
int AutoPosLastDirection;
@ -643,7 +644,7 @@ struct IMGUI_API ImGuiWindow
ImGuiWindow* RootNonPopupWindow; // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself.
ImGuiWindow* ParentWindow; // If we are a child window, this is pointing to our parent window. Else point to NULL.
// Focus
// Navigation / Focus
int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
int FocusIdxTabCounter; // (same, but only count widgets which you can Tab through)
int FocusIdxAllRequestCurrent; // Item being requested for focus
@ -657,6 +658,7 @@ public:
ImGuiID GetID(const char* str, const char* str_end = NULL);
ImGuiID GetID(const void* ptr);
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
@ -701,9 +703,6 @@ namespace ImGui
IMGUI_API void OpenPopupEx(const char* str_id, bool reopen_existing);
inline IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul) { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * alpha_mul; return ImGui::ColorConvertFloat4ToU32(c); }
inline IMGUI_API ImU32 GetColorU32(const ImVec4& col) { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); }
// NB: All position are in absolute pixels coordinates (not window coordinates)
// FIXME: All those functions are a mess and needs to be refactored into something decent. Avoid use outside of imgui.cpp!
// We need: a sort of symbol library, preferably baked into font atlas when possible + decent text rendering helpers.

View File

@ -575,8 +575,8 @@ namespace ImGuiWM
ImColor oSelectedTab(37, 37, 37, 255); // selected
ImColor oBorderColor(72, 72, 72, 255); // border
ImVec2 oRectMin = ImGui::GetItemBoxMin();
ImVec2 oRectMax = ImGui::GetItemBoxMax();
ImVec2 oRectMin = ImGui::GetItemRectMin();
ImVec2 oRectMax = ImGui::GetItemRectMax();
const float fOverlap = 10.f;
const float fSlopWidth = 30.f;

View File

@ -1,5 +1,5 @@
//
// Copyright 2014 Celtoys Ltd
// Copyright 2014-2016 Celtoys Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -128,8 +128,11 @@ static rmtBool g_SettingsInitialized = RMT_FALSE;
#endif
#define RMT_UNREFERENCED_PARAMETER(i) (void)(1 ? (void)0 : ((void)i))
#if 0 //def _MSC_VER
#define RMT_UNREFERENCED_PARAMETER(i) assert(i == 0 || i != 0); // To fool warning C4100 on warning level 4
#else
#define RMT_UNREFERENCED_PARAMETER(i) (void)(1 ? (void)0 : ((void)i))
#endif
#if RMT_USE_CUDA
@ -173,9 +176,9 @@ static void rmtFree( void* ptr )
g_Settings.free( g_Settings.mm_context, ptr );
}
#if RMT_USE_OPENGL
// DLL/Shared Library functions
void* rmtLoadLibrary(const char* path)
static void* rmtLoadLibrary(const char* path)
{
#if defined(RMT_PLATFORM_WINDOWS)
return (void*)LoadLibraryA(path);
@ -198,14 +201,21 @@ static void rmtFreeLibrary(void* handle)
static void* rmtGetProcAddress(void* handle, const char* symbol)
{
#if defined(RMT_PLATFORM_WINDOWS)
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4152) // C4152: nonstandard extension, function/data pointer conversion in expression
#endif
return GetProcAddress((HMODULE)handle, (LPCSTR)symbol);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#elif defined(RMT_PLATFORM_POSIX)
return dlsym(handle, symbol);
#else
return NULL;
#endif
}
#endif
/*
------------------------------------------------------------------------------------------------------------------------
@ -856,8 +866,9 @@ static void VirtualMirrorBuffer_Destructor(VirtualMirrorBuffer* buffer)
*/
typedef struct Thread Thread;
typedef rmtError(*ThreadProc)(Thread* thread);
struct Thread;
typedef rmtError(*ThreadProc)(struct Thread* thread);
typedef struct Thread
{
@ -883,9 +894,6 @@ typedef struct Thread
} Thread;
typedef rmtError (*ThreadProc)(Thread* thread);
#if defined(RMT_PLATFORM_WINDOWS)
static DWORD WINAPI ThreadProcWindows(LPVOID lpParameter)
@ -1046,6 +1054,7 @@ static void Thread_Destructor(Thread* thread)
// NOTE: Microsoft also has its own version of these functions so I'm do some hacky PP to remove them
#define strnlen_s strnlen_s_safe_c
#define strncat_s strncat_s_safe_c
#define strcpy_s strcpy_s_safe_c
#define RSIZE_MAX_STR (4UL << 10) /* 4KB */
@ -1066,7 +1075,7 @@ static void Thread_Destructor(Thread* thread)
typedef int errno_t;
#endif
#if !defined(_WIN64) && !defined(__APPLE__) || defined(__MINGW32__)
#if (!defined(_WIN64) && !defined(__APPLE__)) || (defined(__MINGW32__) && !defined(RSIZE_T_DEFINED))
typedef unsigned int rsize_t;
#endif
@ -1299,6 +1308,79 @@ strncat_s (char *dest, rsize_t dmax, const char *src, rsize_t slen)
}
errno_t
strcpy_s(char *dest, rsize_t dmax, const char *src)
{
const char *overlap_bumper;
if (dest == NULL) {
return RCNEGATE(ESNULLP);
}
if (dmax == 0) {
return RCNEGATE(ESZEROL);
}
if (dmax > RSIZE_MAX_STR) {
return RCNEGATE(ESLEMAX);
}
if (src == NULL) {
*dest = '\0';
return RCNEGATE(ESNULLP);
}
if (dest == src) {
return RCNEGATE(EOK);
}
/* hold base of dest in case src was not copied */
if (dest < src) {
overlap_bumper = src;
while (dmax > 0) {
if (dest == overlap_bumper) {
return RCNEGATE(ESOVRLP);
}
*dest = *src;
if (*dest == '\0') {
return RCNEGATE(EOK);
}
dmax--;
dest++;
src++;
}
}
else {
overlap_bumper = dest;
while (dmax > 0) {
if (src == overlap_bumper) {
return RCNEGATE(ESOVRLP);
}
*dest = *src;
if (*dest == '\0') {
return RCNEGATE(EOK);
}
dmax--;
dest++;
src++;
}
}
/*
* the entire src must have been copied, if not reset dest
* to null the string.
*/
return RCNEGATE(ESNOSPC);
}
/* very simple integer to hex */
static const char* hex_encoding_table = "0123456789ABCDEF";
@ -1681,10 +1763,11 @@ static void TCPSocket_Destructor(TCPSocket* tcp_socket)
}
static rmtError TCPSocket_RunServer(TCPSocket* tcp_socket, rmtU16 port)
static rmtError TCPSocket_RunServer(TCPSocket* tcp_socket, rmtU16 port, rmtBool limit_connections_to_localhost)
{
SOCKET s = INVALID_SOCKET;
struct sockaddr_in sin;
int enable = 1;
#ifdef RMT_PLATFORM_WINDOWS
u_long nonblock = 1;
#endif
@ -1697,9 +1780,23 @@ static rmtError TCPSocket_RunServer(TCPSocket* tcp_socket, rmtU16 port)
if (s == SOCKET_ERROR)
return RMT_ERROR_SOCKET_CREATE_FAIL;
// set SO_REUSEADDR so binding doesn't fail when restarting the application
// (otherwise the same port can't be reused within TIME_WAIT)
// I'm not checking for errors because if this fails (unlikely) we might still
// be able to bind to the socket anyway
#ifdef RMT_PLATFORM_POSIX
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
#elif defined(RMT_PLATFORM_WINDOWS)
// windows also needs SO_EXCLUSEIVEADDRUSE,
// see http://www.andy-pearce.com/blog/posts/2013/Feb/so_reuseaddr-on-windows/
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&enable, sizeof(enable));
enable = 1;
setsockopt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *)&enable, sizeof(enable));
#endif
// Bind the socket to the incoming port
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_addr.s_addr = htonl(limit_connections_to_localhost ? INADDR_LOOPBACK : INADDR_ANY);
sin.sin_port = htons(port);
if (bind(s, (struct sockaddr*)&sin, sizeof(sin)) == SOCKET_ERROR)
return RMT_ERROR_SOCKET_BIND_FAIL;
@ -1816,6 +1913,18 @@ static rmtError TCPSocket_AcceptConnection(TCPSocket* tcp_socket, TCPSocket** cl
if (s == SOCKET_ERROR)
return RMT_ERROR_SOCKET_ACCEPT_FAIL;
#ifdef SO_NOSIGPIPE
// On POSIX systems, send() may send a SIGPIPE signal when writing to an
// already closed connection. By setting this option, we prevent the
// signal from being emitted and send will instead return an error and set
// errno to EPIPE.
//
// This is supported on BSD platforms and not on Linux.
{
int flag = 1;
setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &flag, sizeof(flag));
}
#endif
// Create a client socket for the new connection
assert(client_socket != NULL);
New_0(TCPSocket, *client_socket);
@ -1871,7 +1980,14 @@ static rmtError TCPSocket_Send(TCPSocket* tcp_socket, const void* data, rmtU32 l
while (cur_data < end_data)
{
// Attempt to send the remaining chunk of data
int bytes_sent = (int)send(tcp_socket->socket, cur_data, (int)(end_data - cur_data), 0);
int bytes_sent;
int send_flags = 0;
#ifdef MSG_NOSIGNAL
// On Linux this prevents send from emitting a SIGPIPE signal
// Equivalent on BSD to the SO_NOSIGPIPE option.
send_flags = MSG_NOSIGNAL;
#endif
bytes_sent = (int)send(tcp_socket->socket, cur_data, (int)(end_data - cur_data), send_flags);
if (bytes_sent == SOCKET_ERROR || bytes_sent == 0)
{
@ -2371,9 +2487,10 @@ typedef struct
union
{
rmtU8 data_mask[4];
rmtU32 data_mask_u32;
};
rmtU8 mask[4];
rmtU32 mask_u32;
} data;
} WebSocket;
@ -2536,10 +2653,10 @@ static rmtError WebSocket_Constructor(WebSocket* web_socket, TCPSocket* tcp_sock
web_socket->mode = WEBSOCKET_NONE;
web_socket->frame_bytes_remaining = 0;
web_socket->mask_offset = 0;
web_socket->data_mask[0] = 0;
web_socket->data_mask[1] = 0;
web_socket->data_mask[2] = 0;
web_socket->data_mask[3] = 0;
web_socket->data.mask[0] = 0;
web_socket->data.mask[1] = 0;
web_socket->data.mask[2] = 0;
web_socket->data.mask[3] = 0;
// Caller can optionally specify which TCP socket to use
if (web_socket->tcp_socket == NULL)
@ -2555,12 +2672,12 @@ static void WebSocket_Destructor(WebSocket* web_socket)
}
static rmtError WebSocket_RunServer(WebSocket* web_socket, rmtU32 port, enum WebSocketMode mode)
static rmtError WebSocket_RunServer(WebSocket* web_socket, rmtU16 port, rmtBool limit_connections_to_localhost, enum WebSocketMode mode)
{
// Create the server's listening socket
assert(web_socket != NULL);
web_socket->mode = mode;
return TCPSocket_RunServer(web_socket->tcp_socket, (rmtU16)port);
return TCPSocket_RunServer(web_socket->tcp_socket, port, limit_connections_to_localhost);
}
@ -2728,7 +2845,7 @@ static rmtError ReceiveFrameHeader(WebSocket* web_socket)
mask_present = (msg_header[1] & 0x80) != 0 ? RMT_TRUE : RMT_FALSE;
if (mask_present)
{
error = TCPSocket_Receive(web_socket->tcp_socket, web_socket->data_mask, 4, 20);
error = TCPSocket_Receive(web_socket->tcp_socket, web_socket->data.mask, 4, 20);
if (error != RMT_ERROR_NONE)
return error;
}
@ -2790,12 +2907,12 @@ static rmtError WebSocket_Receive(WebSocket* web_socket, void* data, rmtU32* msg
}
// Apply data mask
if (web_socket->data_mask_u32 != 0)
if (web_socket->data.mask_u32 != 0)
{
rmtU32 i;
for (i = 0; i < bytes_to_read; i++)
{
*((rmtU8*)cur_data + i) ^= web_socket->data_mask[web_socket->mask_offset & 3];
*((rmtU8*)cur_data + i) ^= web_socket->data.mask[web_socket->mask_offset & 3];
web_socket->mask_offset++;
}
}
@ -2892,11 +3009,20 @@ static void MessageQueue_Destructor(MessageQueue* queue)
}
static rmtU32 MessageQueue_SizeForPayload(rmtU32 payload_size)
{
// Add message header and align for ARM platforms
rmtU32 size = sizeof(Message) + payload_size;
size = (size + 3) & ~3U;
return size;
}
static Message* MessageQueue_AllocMessage(MessageQueue* queue, rmtU32 payload_size, struct ThreadSampler* thread_sampler)
{
Message* msg;
rmtU32 write_size = sizeof(Message) + payload_size;
rmtU32 write_size = MessageQueue_SizeForPayload(payload_size);
assert(queue != NULL);
@ -2926,9 +3052,8 @@ static Message* MessageQueue_AllocMessage(MessageQueue* queue, rmtU32 payload_si
}
static void MessageQueue_CommitMessage(MessageQueue* queue, Message* message, MessageID id)
static void MessageQueue_CommitMessage(Message* message, MessageID id)
{
assert(queue != NULL);
assert(message != NULL);
// Ensure message writes complete before commit
@ -2937,8 +3062,6 @@ static void MessageQueue_CommitMessage(MessageQueue* queue, Message* message, Me
// Setting the message ID signals to the consumer that the message is ready
assert(message->id == MsgID_NotReady);
message->id = id;
RMT_UNREFERENCED_PARAMETER(queue);
}
@ -2981,7 +3104,7 @@ static void MessageQueue_ConsumeNextMessage(MessageQueue* queue, Message* messag
// the read position so that a winning thread's allocation will inherit the "not ready" state.
//
// This costs some write bandwidth and has the potential to flush cache to other cores.
message_size = sizeof(Message) + message->payload_size;
message_size = MessageQueue_SizeForPayload(message->payload_size);
memset(message, MsgID_NotReady, message_size);
// Ensure clear completes before advancing the read position
@ -3009,31 +3132,33 @@ typedef struct
rmtU32 last_ping_time;
rmtU16 port;
rmtBool limit_connections_to_localhost;
} Server;
static rmtError Server_CreateListenSocket(Server* server, rmtU16 port)
static rmtError Server_CreateListenSocket(Server* server, rmtU16 port, rmtBool limit_connections_to_localhost)
{
rmtError error = RMT_ERROR_NONE;
New_1(WebSocket, server->listen_socket, NULL);
if (error == RMT_ERROR_NONE)
error = WebSocket_RunServer(server->listen_socket, port, WEBSOCKET_TEXT);
error = WebSocket_RunServer(server->listen_socket, port, limit_connections_to_localhost, WEBSOCKET_TEXT);
return error;
}
static rmtError Server_Constructor(Server* server, rmtU16 port)
static rmtError Server_Constructor(Server* server, rmtU16 port, rmtBool limit_connections_to_localhost)
{
assert(server != NULL);
server->listen_socket = NULL;
server->client_socket = NULL;
server->last_ping_time = 0;
server->port = port;
server->limit_connections_to_localhost = limit_connections_to_localhost;
// Create the listening WebSocket
return Server_CreateListenSocket(server, port);
return Server_CreateListenSocket(server, port, limit_connections_to_localhost);
}
@ -3129,7 +3254,7 @@ static void Server_Update(Server* server)
// Recreate the listening socket if it's been destroyed earlier
if (server->listen_socket == NULL)
Server_CreateListenSocket(server, server->port);
Server_CreateListenSocket(server, server->port, server->limit_connections_to_localhost);
if (server->listen_socket != NULL && server->client_socket == NULL)
{
@ -3303,6 +3428,9 @@ static rmtError json_CloseArray(Buffer* buffer)
#define SAMPLE_NAME_LEN 128
enum SampleType
{
SampleType_CPU,
@ -3324,7 +3452,7 @@ typedef struct Sample
rmtU32 size_bytes;
// Sample name and unique hash
rmtPStr name;
char name[SAMPLE_NAME_LEN];
rmtU32 name_hash;
// Unique, persistent ID among all samples
@ -3343,9 +3471,10 @@ typedef struct Sample
// This is also mixed with the callstack hash to allow consistent addressing of any point in the tree
rmtU32 nb_children;
// Start and end of the sample in microseconds
// Sample end points and length in microseconds
rmtU64 us_start;
rmtU64 us_end;
rmtU64 us_length;
} Sample;
@ -3358,7 +3487,7 @@ static rmtError Sample_Constructor(Sample* sample)
sample->type = SampleType_CPU;
sample->size_bytes = sizeof(Sample);
sample->name = NULL;
sample->name[0] = 0;
sample->name_hash = 0;
sample->unique_id = 0;
sample->unique_id_html_colour[0] = '#';
@ -3371,6 +3500,7 @@ static rmtError Sample_Constructor(Sample* sample)
sample->nb_children = 0;
sample->us_start = 0;
sample->us_end = 0;
sample->us_length = 0;
return RMT_ERROR_NONE;
}
@ -3384,7 +3514,10 @@ static void Sample_Destructor(Sample* sample)
static void Sample_Prepare(Sample* sample, rmtPStr name, rmtU32 name_hash, Sample* parent)
{
sample->name = name;
// Copy sample name away for two reasons:
// 1. It allows dynamic sprintf-style strings to be transient
// 2. The Remotery thread can still inspect the sample even when the source module has been unloaded
strcpy_s(sample->name, sizeof(sample->name), name);
sample->name_hash = name_hash;
sample->unique_id = 0;
sample->parent = parent;
@ -3394,6 +3527,7 @@ static void Sample_Prepare(Sample* sample, rmtPStr name, rmtU32 name_hash, Sampl
sample->nb_children = 0;
sample->us_start = 0;
sample->us_end = 0;
sample->us_length = 0;
}
@ -3416,7 +3550,7 @@ static rmtError json_Sample(Buffer* buffer, Sample* sample)
JSON_ERROR_CHECK(json_Comma(buffer));
JSON_ERROR_CHECK(json_FieldU64(buffer, "us_start", sample->us_start));
JSON_ERROR_CHECK(json_Comma(buffer));
JSON_ERROR_CHECK(json_FieldU64(buffer, "us_length", maxS64(sample->us_end - sample->us_start, 0)));
JSON_ERROR_CHECK(json_FieldU64(buffer, "us_length", maxS64(sample->us_length, 0)));
if (sample->first_child != NULL)
{
@ -3524,7 +3658,7 @@ static rmtU32 HashCombine(rmtU32 hash_a, rmtU32 hash_b)
}
static rmtError SampleTree_Push(SampleTree* tree, rmtPStr name, rmtU32 name_hash, Sample** sample)
static rmtError SampleTree_Push(SampleTree* tree, rmtPStr name, rmtU32 name_hash, rmtU32 flags, Sample** sample)
{
Sample* parent;
rmtError error;
@ -3535,11 +3669,21 @@ static rmtError SampleTree_Push(SampleTree* tree, rmtPStr name, rmtU32 name_hash
assert(tree->current_parent != NULL);
parent = tree->current_parent;
if (parent->last_child != NULL && parent->last_child->name_hash == name_hash)
if ((flags & RMTSF_Aggregate) != 0)
{
// TODO: Collapse siblings with flag exception?
// Note that above check is not enough - requires a linear search
// Linear search for previous instance of this sample name
Sample* sibling;
for (sibling = parent->first_child; sibling != NULL; sibling = sibling->next_sibling)
{
if (sibling->name_hash == name_hash)
{
tree->current_parent = sibling;
*sample = sibling;
return RMT_ERROR_NONE;
}
}
}
if (parent->name_hash == name_hash)
{
// TODO: Collapse recursion on flag?
@ -3657,7 +3801,7 @@ static void AddSampleTreeMessage(MessageQueue* queue, Sample* sample, ObjectAllo
payload->root_sample = sample;
payload->allocator = allocator;
payload->thread_name = thread_name;
MessageQueue_CommitMessage(queue, message, MsgID_SampleTree);
MessageQueue_CommitMessage(message, MsgID_SampleTree);
}
@ -3686,8 +3830,6 @@ typedef struct ThreadSampler
} ThreadSampler;
static rmtS32 countThreads = 0;
static rmtError ThreadSampler_Constructor(ThreadSampler* thread_sampler)
{
rmtError error;
@ -3705,8 +3847,11 @@ static rmtError ThreadSampler_Constructor(ThreadSampler* thread_sampler)
#if defined(RMT_PLATFORM_LINUX) && RMT_USE_POSIX_THREADNAMES
prctl(PR_GET_NAME,thread_sampler->name,0,0,0);
#else
{
static rmtS32 countThreads = 0;
strncat_s(thread_sampler->name, sizeof(thread_sampler->name), "Thread", 6);
itoahex_s(thread_sampler->name + 6, sizeof(thread_sampler->name) - 6, AtomicAdd(&countThreads, 1));
}
#endif
// Create the CPU sample tree only - the rest are created on-demand as they need
@ -3729,10 +3874,9 @@ static void ThreadSampler_Destructor(ThreadSampler* ts)
}
static rmtError ThreadSampler_Push(ThreadSampler* ts, SampleTree* tree, rmtPStr name, rmtU32 name_hash, Sample** sample)
static rmtError ThreadSampler_Push(SampleTree* tree, rmtPStr name, rmtU32 name_hash, rmtU32 flags, Sample** sample)
{
RMT_UNREFERENCED_PARAMETER(ts);
return SampleTree_Push(tree, name, name_hash, sample);
return SampleTree_Push(tree, name, name_hash, flags, sample);
}
@ -3967,7 +4111,7 @@ static rmtError Remotery_SendSampleTreeMessage(Remotery* rmt, Message* message)
{
// If these CUDA samples aren't ready yet, stick them to the back of the queue and continue
rmtBool are_samples_ready;
rmt_BeginCPUSample(AreCUDASamplesReady);
rmt_BeginCPUSample(AreCUDASamplesReady, 0);
are_samples_ready = AreCUDASamplesReady(sample);
rmt_EndCPUSample();
if (!are_samples_ready)
@ -3977,7 +4121,7 @@ static rmtError Remotery_SendSampleTreeMessage(Remotery* rmt, Message* message)
}
// Retrieve timing of all CUDA samples
rmt_BeginCPUSample(GetCUDASampleTimes);
rmt_BeginCPUSample(GetCUDASampleTimes, 0);
GetCUDASampleTimes(sample->parent, sample);
rmt_EndCPUSample();
}
@ -4082,13 +4226,13 @@ static rmtError Remotery_ThreadMain(Thread* thread)
while (thread->request_exit == RMT_FALSE)
{
rmt_BeginCPUSample(Wakeup);
rmt_BeginCPUSample(Wakeup, 0);
rmt_BeginCPUSample(ServerUpdate);
rmt_BeginCPUSample(ServerUpdate, 0);
Server_Update(rmt->server);
rmt_EndCPUSample();
rmt_BeginCPUSample(ConsumeMessageQueue);
rmt_BeginCPUSample(ConsumeMessageQueue, 0);
Remotery_ConsumeMessageQueue(rmt);
rmt_EndCPUSample();
@ -4129,6 +4273,23 @@ static rmtError Remotery_Constructor(Remotery* rmt)
rmt->json_buf = NULL;
rmt->thread = NULL;
#if RMT_USE_CUDA
rmt->cuda.CtxSetCurrent = NULL;
rmt->cuda.EventCreate = NULL;
rmt->cuda.EventDestroy = NULL;
rmt->cuda.EventElapsedTime = NULL;
rmt->cuda.EventQuery = NULL;
rmt->cuda.EventRecord = NULL;
#endif
#if RMT_USE_D3D11
rmt->d3d11 = NULL;
#endif
#if RMT_USE_OPENGL
rmt->opengl = NULL;
#endif
// Kick-off the timer
usTimer_Init(&rmt->timer);
@ -4138,7 +4299,7 @@ static rmtError Remotery_Constructor(Remotery* rmt)
return error;
// Create the server
New_1( Server, rmt->server, g_Settings.port );
New_2(Server, rmt->server, g_Settings.port, g_Settings.limit_connections_to_localhost);
if (error != RMT_ERROR_NONE)
return error;
@ -4152,26 +4313,13 @@ static rmtError Remotery_Constructor(Remotery* rmt)
if (error != RMT_ERROR_NONE)
return error;
#if RMT_USE_CUDA
rmt->cuda.CtxSetCurrent = NULL;
rmt->cuda.EventCreate = NULL;
rmt->cuda.EventDestroy = NULL;
rmt->cuda.EventElapsedTime = NULL;
rmt->cuda.EventQuery = NULL;
rmt->cuda.EventRecord = NULL;
#endif
#if RMT_USE_D3D11
rmt->d3d11 = NULL;
error = D3D11_Create(&rmt->d3d11);
if (error != RMT_ERROR_NONE)
return error;
#endif
#if RMT_USE_OPENGL
rmt->opengl = NULL;
error = OpenGL_Create(&rmt->opengl);
if (error != RMT_ERROR_NONE)
return error;
@ -4198,11 +4346,11 @@ static void Remotery_Destructor(Remotery* rmt)
// Join the remotery thread before clearing the global object as the thread is profiling itself
Delete(Thread, rmt->thread);
// Ensure this is the module that created it
assert(g_RemoteryCreated == RMT_TRUE);
assert(g_Remotery == rmt);
if (g_RemoteryCreated)
{
g_Remotery = NULL;
g_RemoteryCreated = RMT_FALSE;
}
#if RMT_USE_D3D11
Delete(D3D11, rmt->d3d11);
@ -4324,6 +4472,7 @@ RMT_API rmtSettings* _rmt_Settings(void)
if( g_SettingsInitialized == RMT_FALSE )
{
g_Settings.port = 0x4597;
g_Settings.limit_connections_to_localhost = RMT_FALSE;
g_Settings.msSleepBetweenServerUpdates = 10;
g_Settings.messageQueueSizeInBytes = 64 * 1024;
g_Settings.maxNbMessagesPerUpdate = 100;
@ -4357,6 +4506,9 @@ RMT_API rmtError _rmt_CreateGlobalInstance(Remotery** remotery)
RMT_API void _rmt_DestroyGlobalInstance(Remotery* remotery)
{
// Ensure this is the module that created it
assert(g_RemoteryCreated == RMT_TRUE);
assert(g_Remotery == remotery);
Delete(Remotery, remotery);
}
@ -4460,7 +4612,7 @@ static rmtBool QueueLine(MessageQueue* queue, char* text, rmtU32 size, struct Th
// Copy the text and commit the message
memcpy(message->payload, text, size);
MessageQueue_CommitMessage(queue, message, MsgID_LogText);
MessageQueue_CommitMessage(message, MsgID_LogText);
return RMT_TRUE;
}
@ -4554,7 +4706,7 @@ static rmtU32 GetNameHash(rmtPStr name, rmtU32* hash_cache)
}
RMT_API void _rmt_BeginCPUSample(rmtPStr name, rmtU32* hash_cache)
RMT_API void _rmt_BeginCPUSample(rmtPStr name, rmtU32 flags, rmtU32* hash_cache)
{
// 'hash_cache' stores a pointer to a sample name's hash value. Internally this is used to identify unique callstacks and it
// would be ideal that it's not recalculated each time the sample is used. This can be statically cached at the point
@ -4573,9 +4725,15 @@ RMT_API void _rmt_BeginCPUSample(rmtPStr name, rmtU32* hash_cache)
{
Sample* sample;
rmtU32 name_hash = GetNameHash(name, hash_cache);
if (ThreadSampler_Push(ts, ts->sample_trees[SampleType_CPU], name, name_hash, &sample) == RMT_ERROR_NONE)
if (ThreadSampler_Push(ts->sample_trees[SampleType_CPU], name, name_hash, flags, &sample) == RMT_ERROR_NONE)
{
// If this is an aggregate sample, store the time in 'end' as we want to preserve 'start'
if (sample->us_length != 0)
sample->us_end = usTimer_Get(&g_Remotery->timer);
else
sample->us_start = usTimer_Get(&g_Remotery->timer);
}
}
}
@ -4589,6 +4747,21 @@ RMT_API void _rmt_EndCPUSample(void)
if (Remotery_GetThreadSampler(g_Remotery, &ts) == RMT_ERROR_NONE)
{
Sample* sample = ts->sample_trees[SampleType_CPU]->current_parent;
rmtU64 us_end = usTimer_Get(&g_Remotery->timer);
// Is this an aggregate sample?
if (sample->us_length != 0)
{
sample->us_length += (us_end - sample->us_end);
sample->us_end = us_end;
}
else
{
sample->us_end = us_end;
sample->us_length = (us_end - sample->us_start);
}
sample->us_end = usTimer_Get(&g_Remotery->timer);
ThreadSampler_Pop(ts, g_Remotery->mq_to_rmt_thread, sample);
}
@ -4794,6 +4967,7 @@ static rmtBool GetCUDASampleTimes(Sample* root_sample, Sample* sample)
// Convert to microseconds and add to the sample
sample->us_start = (rmtU64)(ms_start * 1000);
sample->us_end = (rmtU64)(ms_end * 1000);
sample->us_length = sample->us_end - sample->us_start;
// Get child sample times
for (child = sample->first_child; child != NULL; child = child->next_sibling)
@ -4847,7 +5021,7 @@ RMT_API void _rmt_BeginCUDASample(rmtPStr name, rmtU32* hash_cache, void* stream
}
// Push the same and record its event
if (ThreadSampler_Push(ts, *cuda_tree, name, name_hash, &sample) == RMT_ERROR_NONE)
if (ThreadSampler_Push(*cuda_tree, name, name_hash, 0, &sample) == RMT_ERROR_NONE)
{
CUDASample* cuda_sample = (CUDASample*)sample;
CUDAEventRecord(cuda_sample->event_start, stream);
@ -5233,7 +5407,7 @@ RMT_API void _rmt_BeginD3D11Sample(rmtPStr name, rmtU32* hash_cache)
New_3(ObjectAllocator, d3d11->timestamp_allocator, sizeof(D3D11Timestamp), (ObjConstructor)D3D11Timestamp_Constructor, (ObjDestructor)D3D11Timestamp_Destructor);
// Push the sample
if (ThreadSampler_Push(ts, *d3d_tree, name, name_hash, &sample) == RMT_ERROR_NONE)
if (ThreadSampler_Push(*d3d_tree, name, name_hash, 0, &sample) == RMT_ERROR_NONE)
{
D3D11Sample* d3d_sample = (D3D11Sample*)sample;
@ -5273,6 +5447,8 @@ static rmtBool GetD3D11SampleTimes(Sample* sample, rmtU64* out_first_timestamp)
d3d11->last_error = result;
return RMT_FALSE;
}
sample->us_length = sample->us_end - sample->us_start;
}
// Get child sample times
@ -5296,7 +5472,7 @@ static void UpdateD3D11Frame(void)
d3d11 = g_Remotery->d3d11;
assert(d3d11 != NULL);
rmt_BeginCPUSample(rmt_UpdateD3D11Frame);
rmt_BeginCPUSample(rmt_UpdateD3D11Frame, 0);
// Process all messages in the D3D queue
for (;;)
@ -5506,8 +5682,7 @@ static void* rmtglGetProcAddress(OpenGL* opengl, const char* symbol)
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
extern void* nsglGetProcAddress(const GLubyte* _name);
return nsglGetProcAddress((const GLubyte*)symbol);
return NSGLGetProcAddress((const GLubyte*)symbol);
#elif defined(RMT_PLATFORM_LINUX)
@ -5820,7 +5995,7 @@ RMT_API void _rmt_BeginOpenGLSample(rmtPStr name, rmtU32* hash_cache)
New_3(ObjectAllocator, opengl->timestamp_allocator, sizeof(OpenGLTimestamp), (ObjConstructor)OpenGLTimestamp_Constructor, (ObjDestructor)OpenGLTimestamp_Destructor);
// Push the sample
if (ThreadSampler_Push(ts, *ogl_tree, name, name_hash, &sample) == RMT_ERROR_NONE)
if (ThreadSampler_Push(*ogl_tree, name, name_hash, 0, &sample) == RMT_ERROR_NONE)
{
OpenGLSample* ogl_sample = (OpenGLSample*)sample;
@ -5845,6 +6020,8 @@ static rmtBool GetOpenGLSampleTimes(Sample* sample, rmtU64* out_first_timestamp)
{
if (!OpenGLTimestamp_GetData(ogl_sample->timestamp, &sample->us_start, &sample->us_end, out_first_timestamp))
return RMT_FALSE;
sample->us_length = sample->us_end - sample->us_start;
}
// Get child sample times
@ -5868,7 +6045,7 @@ static void UpdateOpenGLFrame(void)
opengl = g_Remotery->opengl;
assert(opengl != NULL);
rmt_BeginCPUSample(rmt_UpdateOpenGLFrame);
rmt_BeginCPUSample(rmt_UpdateOpenGLFrame, 0);
// Process all messages in the OpenGL queue
while (1)

View File

@ -82,17 +82,6 @@ documented just below this comment.
*/
// Compiler identification
#if defined(_MSC_VER)
#define RMT_COMPILER_MSVC
#elif defined(__GNUC__)
#define RMT_COMPILER_GNUC
#elif defined(__clang__)
#define RMT_COMPILER_CLANG
#endif
// Platform identification
#if defined(_WINDOWS) || defined(_WIN32)
#define RMT_PLATFORM_WINDOWS
@ -254,6 +243,15 @@ typedef enum rmtError
} rmtError;
typedef enum rmtSampleFlags
{
// Default behaviour
RMTSF_None = 0,
// Search parent for same-named samples and merge timing instead of adding a new sample
RMTSF_Aggregate = 1,
} rmtSampleFlags;
/*
------------------------------------------------------------------------------------------------------------------------
@ -289,14 +287,14 @@ typedef enum rmtError
#define rmt_LogText(text) \
RMT_OPTIONAL(RMT_ENABLED, _rmt_LogText(text))
#define rmt_BeginCPUSample(name) \
#define rmt_BeginCPUSample(name, flags) \
RMT_OPTIONAL(RMT_ENABLED, { \
static rmtU32 rmt_sample_hash_##name = 0; \
_rmt_BeginCPUSample(#name, &rmt_sample_hash_##name); \
_rmt_BeginCPUSample(#name, flags, &rmt_sample_hash_##name); \
})
#define rmt_BeginCPUSampleDynamic(namestr) \
RMT_OPTIONAL(RMT_ENABLED, _rmt_BeginCPUSample(namestr, NULL))
#define rmt_BeginCPUSampleDynamic(namestr, flags) \
RMT_OPTIONAL(RMT_ENABLED, _rmt_BeginCPUSample(namestr, flags, NULL))
#define rmt_EndCPUSample() \
RMT_OPTIONAL(RMT_ENABLED, _rmt_EndCPUSample())
@ -312,8 +310,15 @@ typedef void (*rmtInputHandlerPtr)(const char* text, void* context);
// Struture to fill in to modify Remotery default settings
typedef struct rmtSettings
{
// Which port to listen for incoming connections on
rmtU16 port;
// Only allow connections on localhost?
// For dev builds you may want to access your game from other devices but if
// you distribute a game to your players with Remotery active, probably best
// to limit connections to localhost.
rmtBool limit_connections_to_localhost;
// How long to sleep between server updates, hopefully trying to give
// a little CPU back to other threads.
rmtU32 msSleepBetweenServerUpdates;
@ -485,8 +490,8 @@ struct rmt_EndOpenGLSampleOnScopeExit
// Pairs a call to rmt_Begin<TYPE>Sample with its call to rmt_End<TYPE>Sample when leaving scope
#define rmt_ScopedCPUSample(name) \
RMT_OPTIONAL(RMT_ENABLED, rmt_BeginCPUSample(name)); \
#define rmt_ScopedCPUSample(name, flags) \
RMT_OPTIONAL(RMT_ENABLED, rmt_BeginCPUSample(name, flags)); \
RMT_OPTIONAL(RMT_ENABLED, rmt_EndCPUSampleOnScopeExit rmt_ScopedCPUSample##name);
#define rmt_ScopedCUDASample(name, stream) \
RMT_OPTIONAL(RMT_USE_CUDA, rmt_BeginCUDASample(name, stream)); \
@ -525,7 +530,7 @@ RMT_API void _rmt_SetGlobalInstance(Remotery* remotery);
RMT_API Remotery* _rmt_GetGlobalInstance(void);
RMT_API void _rmt_SetCurrentThreadName(rmtPStr thread_name);
RMT_API void _rmt_LogText(rmtPStr text);
RMT_API void _rmt_BeginCPUSample(rmtPStr name, rmtU32* hash_cache);
RMT_API void _rmt_BeginCPUSample(rmtPStr name, rmtU32 flags, rmtU32* hash_cache);
RMT_API void _rmt_EndCPUSample(void);
#if RMT_USE_CUDA

View File

@ -54,14 +54,14 @@ See the sample directory for further examples. A quick example:
// Explicit begin/end for C
{
rmt_BeginCPUSample(LogText);
rmt_BeginCPUSample(LogText, 0);
rmt_LogText("Time me, please!");
rmt_EndCPUSample();
}
// Scoped begin/end for C++
{
rmt_ScopedCPUSample(LogText);
rmt_ScopedCPUSample(LogText, 0);
rmt_LogText("Time me, too!");
}

View File

@ -1,12 +1,14 @@
#include <stdlib.h>
#include <math.h>
#include <signal.h>
#include <stdio.h>
#include "Remotery.h"
double delay() {
int i, end;
double j = 0;
rmt_BeginCPUSample(delay);
rmt_BeginCPUSample(delay, 0);
for( i = 0, end = rand()/100; i < end; ++i ) {
j += sin(i);
}
@ -14,20 +16,30 @@ double delay() {
return j;
}
int sig = 0;
/// Allow to close cleanly with ctrl + c
void sigintHandler(int sig_num) {
sig = sig_num;
printf("Interrupted\n");
}
int main( ) {
signal(SIGINT, sigintHandler);
int main( int argc, const char **argv ) {
Remotery *rmt;
if( RMT_ERROR_NONE != rmt_CreateGlobalInstance(&rmt) ) {
return -1;
}
for(;;) {
while (sig == 0) {
rmt_LogText("start profiling");
delay();
rmt_LogText("end profiling");
}
rmt_DestroyGlobalInstance(rmt);
printf("Cleaned up and quit\n");
return 0;
}

View File

@ -19,7 +19,16 @@ Console = (function()
// This accumulates log text as fast as is required
this.PageTextBuffer = "";
this.LastPageTextBufferLen = 0;
this.AppTextBuffer = "";
this.LastAppTextBufferLen = 0;
// Setup command history control
this.CommandHistory = LocalStore.Get("App", "Global", "CommandHistory", [ ]);
this.CommandIndex = 0;
this.MaxNbCommands = 200;
DOM.Event.AddHandler(this.UserInput.EditNode, "keydown", Bind(OnKeyPress, this));
DOM.Event.AddHandler(this.UserInput.EditNode, "focus", Bind(OnFocus, this));
// At a much lower frequency this will update the console window
window.setInterval(Bind(UpdateHTML, this), 500);
@ -91,13 +100,21 @@ Console = (function()
{
// Reset the current text buffer as html
if (self.LastPageTextBufferLen != self.PageTextBuffer.length)
{
var page_node = self.PageContainer.Node;
page_node.innerHTML = self.PageTextBuffer;
page_node.scrollTop = page_node.scrollHeight;
self.LastPageTextBufferLen = self.PageTextBuffer.length;
}
if (self.LastAppTextBufferLen != self.AppTextBuffer.length)
{
var app_node = self.AppContainer.Node;
app_node.innerHTML = self.AppTextBuffer;
app_node.scrollTop = app_node.scrollHeight;
self.LastAppTextBufferLen = self.AppTextBuffer.length;
}
}
@ -110,6 +127,64 @@ Console = (function()
// Emit to console and clear
self.Log("> " + msg);
self.UserInput.SetValue("");
// Keep track of recently issued commands, with an upper bound
self.CommandHistory.push(msg);
var extra_commands = self.CommandHistory.length - self.MaxNbCommands;
if (extra_commands > 0)
self.CommandHistory.splice(0, extra_commands);
// Set command history index to the most recent command
self.CommandIndex = self.CommandHistory.length;
// Backup to local store
LocalStore.Set("App", "Global", "CommandHistory", self.CommandHistory);
// Keep focus with the edit box
return true;
}
function OnKeyPress(self, evt)
{
evt = DOM.Event.Get(evt);
if (evt.keyCode == Keyboard.Codes.UP)
{
if (self.CommandHistory.length > 0)
{
// Cycle backwards through the command history
self.CommandIndex--;
if (self.CommandIndex < 0)
self.CommandIndex = self.CommandHistory.length - 1;
var command = self.CommandHistory[self.CommandIndex];
self.UserInput.SetValue(command);
}
// Stops default behaviour of moving cursor to the beginning
DOM.Event.StopDefaultAction(evt);
}
else if (evt.keyCode == Keyboard.Codes.DOWN)
{
if (self.CommandHistory.length > 0)
{
// Cycle fowards through the command history
self.CommandIndex = (self.CommandIndex + 1) % self.CommandHistory.length;
var command = self.CommandHistory[self.CommandIndex];
self.UserInput.SetValue(command);
}
// Stops default behaviour of moving cursor to the end
DOM.Event.StopDefaultAction(evt);
}
}
function OnFocus(self)
{
// Reset command index on focus
self.CommandIndex = self.CommandHistory.length;
}

View File

@ -92,6 +92,9 @@ Remotery = (function()
// Update and disconnect, relying on auto-connect to reconnect
self.ConnectionAddress = node.value;
self.Server.Disconnect();
// Give input focus away
return false;
}

View File

@ -67,6 +67,7 @@ body
color: #BBB;
font: 9px Verdana;
margin: 2px;
white-space: pre;
}

View File

@ -27,11 +27,12 @@ WM.EditBox = (function()
this.SetPosition(x, y);
this.SetSize(w, h);
this.PreviousValue = "";
// Hook up the event handlers
DOM.Event.AddHandler(this.EditNode, "focus", Bind(OnFocus, this));
DOM.Event.AddHandler(this.EditNode, "keypress", Bind(OnKeyPress, this));
DOM.Event.AddHandler(this.EditNode, "keydown", Bind(OnKeyDown, this));
DOM.Event.AddHandler(this.EditNode, "change", Bind(OnChange, this));
}
@ -88,9 +89,12 @@ WM.EditBox = (function()
function OnKeyPress(self, evt)
{
// Allow enter to confirm the text only when there's data
if (evt.keyCode == 13 && self.EditNode.value != "")
if (evt.keyCode == 13 && self.EditNode.value != "" && self.ChangeHandler)
{
var focus = self.ChangeHandler(self.EditNode);
if (!focus)
self.EditNode.blur();
self.PreviousValue = "";
}
}
@ -99,19 +103,17 @@ WM.EditBox = (function()
{
// Allow escape to cancel any text changes
if (evt.keyCode == 27)
{
// On initial edit of the input, escape should NOT replace with the empty string
if (self.PreviousValue != "")
{
self.EditNode.value = self.PreviousValue;
}
self.EditNode.blur();
}
}
function OnChange(self, evt)
{
if (self.ChangeHandler)
self.ChangeHandler(self.EditNode);
}
return EditBox;
})();

View File

@ -17,6 +17,7 @@
<script type="text/javascript" src="extern/BrowserLib/Core/Code/Convert.js"></script>
<script type="text/javascript" src="extern/BrowserLib/Core/Code/LocalStore.js"></script>
<script type="text/javascript" src="extern/BrowserLib/Core/Code/Mouse.js"></script>
<script type="text/javascript" src="extern/BrowserLib/Core/Code/Keyboard.js"></script>
<!-- User Interface Window Manager -->
<script type="text/javascript" src="extern/BrowserLib/WindowManager/Code/WindowManager.js"></script>

View File

@ -29,11 +29,13 @@
#endif
#if defined(WIN32)
#define RENDERDOC_CC __cdecl
#define RENDERDOC_CC __cdecl
#elif defined(__linux__)
#define RENDERDOC_CC
#define RENDERDOC_CC
#elif defined(__APPLE__)
#define RENDERDOC_CC
#else
#error "Unknown platform"
#error "Unknown platform"
#endif
#ifdef __cplusplus
@ -45,11 +47,18 @@ extern "C" {
// This is a GUID/magic value used for when applications pass a path where shader debug
// information can be found to match up with a stripped shader.
// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue = RENDERDOC_ShaderDebugMagicValue_value
#define RENDERDOC_ShaderDebugMagicValue_struct { 0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff }
// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue =
// RENDERDOC_ShaderDebugMagicValue_value
#define RENDERDOC_ShaderDebugMagicValue_struct \
{ \
0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// as an alternative when you want a byte array (assuming x86 endianness):
#define RENDERDOC_ShaderDebugMagicValue_bytearray { 0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff }
#define RENDERDOC_ShaderDebugMagicValue_bytearray \
{ \
0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// truncated version when only a uint64_t is available (e.g. Vulkan tags):
#define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL
@ -58,8 +67,7 @@ extern "C" {
// RenderDoc capture options
//
typedef enum
{
typedef enum {
// Allow the application to enable vsync
//
// Default - enabled
@ -83,7 +91,8 @@ typedef enum
// 1 - Enable built-in API debugging features and records the results into
// the capture logfile, which is matched up with events on replay
// 0 - no API debugging is forcibly enabled
eRENDERDOC_Option_DebugDeviceMode = 2,
eRENDERDOC_Option_APIValidation = 2,
eRENDERDOC_Option_DebugDeviceMode = 2, // deprecated name of this enum
// Capture CPU callstacks for API events
//
@ -169,7 +178,7 @@ typedef enum
// the period when a frame capture is in progress.
eRENDERDOC_Option_CaptureAllCmdLists = 10,
// Mute API debugging output when the debug device mode option is enabled
// Mute API debugging output when the API validation mode option is enabled
//
// Default - enabled
//
@ -183,21 +192,20 @@ typedef enum
//
// Returns 1 if the option and value are valid
// Returns 0 if either is invalid and the option is unchanged
typedef int (RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
typedef int (RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
// Gets the current value of an option as a uint32_t
//
// If the option is invalid, 0xffffffff is returned
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
// Gets the current value of an option as a float
//
// If the option is invalid, -FLT_MAX is returned
typedef float (RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
typedef float(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
typedef enum
{
typedef enum {
// '0' - '9' matches ASCII values
eRENDERDOC_Key_0 = 0x30,
eRENDERDOC_Key_1 = 0x31,
@ -278,15 +286,14 @@ typedef enum
// Sets which key or keys can be used to toggle focus between multiple windows
//
// If keys is NULL or num is 0, toggle keys will be disabled
typedef void (RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
typedef void(RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
// Sets which key or keys can be used to capture the next frame
//
// If keys is NULL or num is 0, captures keys will be disabled
typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
typedef enum
{
typedef enum {
// This single bit controls whether the overlay is enabled or disabled globally
eRENDERDOC_Overlay_Enabled = 0x1,
@ -300,11 +307,8 @@ typedef enum
eRENDERDOC_Overlay_CaptureList = 0x8,
// Default values for the overlay mask
eRENDERDOC_Overlay_Default =
(eRENDERDOC_Overlay_Enabled|
eRENDERDOC_Overlay_FrameRate|
eRENDERDOC_Overlay_FrameNumber|
eRENDERDOC_Overlay_CaptureList),
eRENDERDOC_Overlay_Default = (eRENDERDOC_Overlay_Enabled | eRENDERDOC_Overlay_FrameRate |
eRENDERDOC_Overlay_FrameNumber | eRENDERDOC_Overlay_CaptureList),
// Enable all bits
eRENDERDOC_Overlay_All = ~0U,
@ -314,9 +318,9 @@ typedef enum
} RENDERDOC_OverlayBits;
// returns the overlay bits that have been set
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
// sets the overlay bits with an and & or mask
typedef void (RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
// this function will attempt to shut down RenderDoc.
//
@ -324,14 +328,14 @@ typedef void (RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t O
// the dll is loaded, before any API work happens. RenderDoc will remove its
// injected hooks and shut down. Behaviour is undefined if this is called
// after any API functions have been called.
typedef void (RENDERDOC_CC *pRENDERDOC_Shutdown)();
typedef void(RENDERDOC_CC *pRENDERDOC_Shutdown)();
// This function will unload RenderDoc's crash handler.
//
// If you use your own crash handler and don't want RenderDoc's handler to
// intercede, you can call this function to unload it and any unhandled
// exceptions will pass to the next handler.
typedef void (RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
// Sets the logfile path template
//
@ -350,13 +354,13 @@ typedef void (RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
//
// Capture #1 -> my_captures/example_frame123.rdc
// Capture #2 -> my_captures/example_frame456.rdc
typedef void (RENDERDOC_CC *pRENDERDOC_SetLogFilePathTemplate)(const char *pathtemplate);
typedef void(RENDERDOC_CC *pRENDERDOC_SetLogFilePathTemplate)(const char *pathtemplate);
// returns the current logfile template, see SetLogFileTemplate above, as a UTF-8 string
typedef const char* (RENDERDOC_CC *pRENDERDOC_GetLogFilePathTemplate)();
typedef const char *(RENDERDOC_CC *pRENDERDOC_GetLogFilePathTemplate)();
// returns the number of captures that have been made
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
// This function returns the details of a capture, by index. New captures are added
// to the end of the list.
@ -372,13 +376,11 @@ typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
//
// Note: when captures are deleted in the UI they will remain in this list, so the
// logfile path may not exist anymore.
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *logfile, uint32_t *pathlength, uint64_t *timestamp);
// capture the next frame on whichever window and API is currently considered active
typedef void (RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *logfile,
uint32_t *pathlength, uint64_t *timestamp);
// returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_IsRemoteAccessConnected)();
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsRemoteAccessConnected)();
// This function will launch the Replay UI associated with the RenderDoc library injected
// into the running application.
@ -389,12 +391,13 @@ typedef uint32_t (RENDERDOC_CC *pRENDERDOC_IsRemoteAccessConnected)();
// if cmdline is NULL, the command line will be empty.
//
// returns the PID of the replay UI if successful, 0 if not successful.
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectRemoteAccess, const char *cmdline);
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectRemoteAccess,
const char *cmdline);
// RenderDoc can return a higher version than requested if it's backwards compatible,
// this function returns the actual version returned. If a parameter is NULL, it will be
// ignored and the others will be filled out.
typedef void (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
typedef void(RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
//////////////////////////////////////////////////////////////////////////
// Capturing functions
@ -403,16 +406,23 @@ typedef void (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, in
// A device pointer is a pointer to the API's root handle.
//
// This would be an ID3D11Device, HGLRC/GLXContext, ID3D12Device, etc
typedef void* RENDERDOC_DevicePointer;
typedef void *RENDERDOC_DevicePointer;
// A window handle is the OS's native window handle
//
// This would be an HWND, GLXDrawable, etc
typedef void* RENDERDOC_WindowHandle;
typedef void *RENDERDOC_WindowHandle;
// This sets the RenderDoc in-app overlay in the API/window pair as 'active' and it will
// respond to keypresses. Neither parameter can be NULL
typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// capture the next frame on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
// capture the next N frames on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames);
// When choosing either a device pointer or a window handle to capture, you can pass NULL.
// Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
@ -432,17 +442,19 @@ typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer
//
// The results are undefined (including crashes) if two captures are started overlapping,
// even on separate devices and/oror windows.
typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
typedef void(RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Returns whether or not a frame capture is currently ongoing anywhere.
//
// This will return 1 if a capture is ongoing, and 0 if there is no capture running
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
// Ends capturing immediately.
//
// This will return 1 if the capture succeeded, and 0 if there was an error capturing.
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API versions
@ -457,10 +469,11 @@ typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePoin
// Note that this means the API returned can be higher than the one you might have requested.
// e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
// instead of 1.0.0. You can check this with the GetAPIVersion entry point
typedef enum
{
typedef enum {
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 00 00
eRENDERDOC_API_Version_1_0_1 = 10001, // RENDERDOC_API_1_0_1 = 1 00 01
eRENDERDOC_API_Version_1_0_2 = 10002, // RENDERDOC_API_1_0_2 = 1 00 02
eRENDERDOC_API_Version_1_1_0 = 10100, // RENDERDOC_API_1_1_0 = 1 01 00
} RENDERDOC_Version;
// API version changelog:
@ -468,8 +481,11 @@ typedef enum
// 1.0.0 - initial release
// 1.0.1 - Bugfix: IsFrameCapturing() was returning false for captures that were triggered
// by keypress or TriggerCapture, instead of Start/EndFrameCapture.
// 1.0.2 - Refactor: Renamed eRENDERDOC_Option_DebugDeviceMode to eRENDERDOC_Option_APIValidation
// 1.1.0 - Add feature: TriggerMultiFrameCapture(). Backwards compatible with 1.0.x since the new
// function pointer is added to the end of the struct, the original layout is identical
// eRENDERDOC_API_Version_1_0_1
// eRENDERDOC_API_Version_1_1_0
typedef struct
{
pRENDERDOC_GetAPIVersion GetAPIVersion;
@ -505,9 +521,13 @@ typedef struct
pRENDERDOC_StartFrameCapture StartFrameCapture;
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
pRENDERDOC_EndFrameCapture EndFrameCapture;
} RENDERDOC_API_1_0_1;
typedef RENDERDOC_API_1_0_1 RENDERDOC_API_1_0_0;
pRENDERDOC_TriggerMultiFrameCapture TriggerMultiFrameCapture;
} RENDERDOC_API_1_1_0;
typedef RENDERDOC_API_1_1_0 RENDERDOC_API_1_0_0;
typedef RENDERDOC_API_1_1_0 RENDERDOC_API_1_0_1;
typedef RENDERDOC_API_1_1_0 RENDERDOC_API_1_0_2;
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API entry point
@ -531,7 +551,7 @@ typedef RENDERDOC_API_1_0_1 RENDERDOC_API_1_0_0;
// 1 - if the outAPIPointers has been filled with a pointer to the API struct requested
// 0 - if the requested version is not supported or the arguments are invalid.
//
typedef int (RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
typedef int(RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
#ifdef __cplusplus
} // extern "C"

View File

@ -1375,18 +1375,18 @@ static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int r
// convert source image with img_n components to one with req_comp components;
// avoid switch per pixel, so use switch per scanline and massive macros
switch (COMBO(img_n, req_comp)) {
CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break;
CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break;
CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break;
CASE(2,1) { dest[0]=src[0]; } break;
CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break;
CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break;
CASE(3,4) { dest[0]=src[0]; dest[1]=src[1]; dest[2]=src[2]; dest[3]=255; } break;
CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break;
CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break;
CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break;
CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break;
CASE(4,3) { dest[0]=src[0]; dest[1]=src[1]; dest[2]=src[2]; } break;
CASE(1,2) dest[0]=src[0], dest[1]=255; break;
CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break;
CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break;
CASE(2,1) dest[0]=src[0]; break;
CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break;
CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break;
CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break;
CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break;
CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; break;
CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break;
CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break;
CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break;
default: STBI_ASSERT(0);
}
#undef CASE
@ -4101,12 +4101,12 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r
switch (filter) {
// "none" filter turns into a memcpy here; make that explicit.
case STBI__F_none: memcpy(cur, raw, nk); break;
CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break;
CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;
CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break;
CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break;
CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break;
CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break;
CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); break;
CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break;
CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); break;
CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); break;
CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); break;
CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); break;
}
#undef CASE
raw += nk;
@ -4117,13 +4117,13 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r
for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \
for (k=0; k < filter_bytes; ++k)
switch (filter) {
CASE(STBI__F_none) { cur[k] = raw[k]; } break;
CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break;
CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;
CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break;
CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break;
CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break;
CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break;
CASE(STBI__F_none) cur[k] = raw[k]; break;
CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); break;
CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break;
CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); break;
CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); break;
CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); break;
CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); break;
}
#undef CASE

View File

@ -139,7 +139,6 @@ https://github.com/mamedev/mame MAME - Multiple Arcade Machine Emulator
https://blackshift.itch.io/blackshift - Blackshift is a grid-based, space-themed
action puzzle game which isn't afraid of complexity — think Chip's Challenge on
crack.
https://www.youtube.com/watch?v=PUl8612Y-ds
<a href="http://www.youtube.com/watch?feature=player_embedded&v=PUl8612Y-ds
" target="_blank"><img src="http://img.youtube.com/vi/PUl8612Y-ds/0.jpg"
alt="Blackshift Trailer, May 2016"
@ -150,7 +149,15 @@ with Linearly Transformed Cosines, Eric Heitz, Jonathan Dupuy, Stephen Hill and
David Neubelt, ACM SIGGRAPH 2016
<a href="http://www.youtube.com/watch?feature=player_embedded&v=ZLRgEN7AQgM
" target="_blank"><img src="http://img.youtube.com/vi/ZLRgEN7AQgM/0.jpg"
alt="Real-Time Polygonal-Light Shading with Linearly Transformed Cosines "
alt="Real-Time Polygonal-Light Shading with Linearly Transformed Cosines"
width="640" height="480" border="0" /></a>
http://www.dogbytegames.com/dead_venture.html - Dead Venture is a new Drive 'N
Gun game where you help a handful of survivals reach the safe haven: a military
base on a far island.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=CgMr1g12yXw
" target="_blank"><img src="http://img.youtube.com/vi/CgMr1g12yXw/0.jpg"
alt="Dead Venture - Gameplay Teaser (iOS / Android)"
width="640" height="480" border="0" /></a>
[License (BSD 2-clause)](https://bkaradzic.github.io/bgfx/license.html)

View File

@ -23,7 +23,7 @@ using namespace std::tr1;
#include <bx/timer.h>
#include <bx/allocator.h>
#include <bx/hash.h>
#include <bx/float4_t.h>
#include <bx/simd_t.h>
#include <bx/fpumath.h>
#include <bx/crtimpl.h>
#include "entry/entry.h"
@ -1513,9 +1513,9 @@ void shadowVolumeCreate(ShadowVolume& _shadowVolume
using namespace bx;
const float4_t lx = float4_splat(_light[0]);
const float4_t ly = float4_splat(_light[1]);
const float4_t lz = float4_splat(_light[2]);
const simd128_t lx = simd_splat(_light[0]);
const simd128_t ly = simd_splat(_light[1]);
const simd128_t lz = simd_splat(_light[2]);
for (; ii < numEdgesRounded; ii+=2)
{
@ -1524,47 +1524,47 @@ void shadowVolumeCreate(ShadowVolume& _shadowVolume
const Plane* edgePlane0 = &edgePlanes[ii*2];
const Plane* edgePlane1 = &edgePlanes[ii*2 + 2];
const float4_t reverse =
float4_ild(edge0.m_faceReverseOrder[0]
const simd128_t reverse =
simd_ild(edge0.m_faceReverseOrder[0]
, edge1.m_faceReverseOrder[0]
, edge0.m_faceReverseOrder[1]
, edge1.m_faceReverseOrder[1]
);
const float4_t p00 = float4_ld(edgePlane0[0].m_plane);
const float4_t p10 = float4_ld(edgePlane1[0].m_plane);
const float4_t p01 = float4_ld(edgePlane0[1].m_plane);
const float4_t p11 = float4_ld(edgePlane1[1].m_plane);
const simd128_t p00 = simd_ld(edgePlane0[0].m_plane);
const simd128_t p10 = simd_ld(edgePlane1[0].m_plane);
const simd128_t p01 = simd_ld(edgePlane0[1].m_plane);
const simd128_t p11 = simd_ld(edgePlane1[1].m_plane);
const float4_t xxyy0 = float4_shuf_xAyB(p00, p01);
const float4_t zzww0 = float4_shuf_zCwD(p00, p01);
const float4_t xxyy1 = float4_shuf_xAyB(p10, p11);
const float4_t zzww1 = float4_shuf_zCwD(p10, p11);
const simd128_t xxyy0 = simd_shuf_xAyB(p00, p01);
const simd128_t zzww0 = simd_shuf_zCwD(p00, p01);
const simd128_t xxyy1 = simd_shuf_xAyB(p10, p11);
const simd128_t zzww1 = simd_shuf_zCwD(p10, p11);
const float4_t vX = float4_shuf_xAyB(xxyy0, xxyy1);
const float4_t vY = float4_shuf_zCwD(xxyy0, xxyy1);
const float4_t vZ = float4_shuf_xAyB(zzww0, zzww1);
const float4_t vW = float4_shuf_zCwD(zzww0, zzww1);
const simd128_t vX = simd_shuf_xAyB(xxyy0, xxyy1);
const simd128_t vY = simd_shuf_zCwD(xxyy0, xxyy1);
const simd128_t vZ = simd_shuf_xAyB(zzww0, zzww1);
const simd128_t vW = simd_shuf_zCwD(zzww0, zzww1);
const float4_t r0 = float4_mul(vX, lx);
const float4_t r1 = float4_mul(vY, ly);
const float4_t r2 = float4_mul(vZ, lz);
const simd128_t r0 = simd_mul(vX, lx);
const simd128_t r1 = simd_mul(vY, ly);
const simd128_t r2 = simd_mul(vZ, lz);
const float4_t dot = float4_add(r0, float4_add(r1, r2) );
const float4_t f = float4_add(dot, vW);
const simd128_t dot = simd_add(r0, simd_add(r1, r2) );
const simd128_t f = simd_add(dot, vW);
const float4_t zero = float4_zero();
const float4_t mask = float4_cmpgt(f, zero);
const float4_t onef = float4_splat(1.0f);
const float4_t tmp0 = float4_and(mask, onef);
const float4_t tmp1 = float4_ftoi(tmp0);
const float4_t tmp2 = float4_xor(tmp1, reverse);
const float4_t tmp3 = float4_sll(tmp2, 1);
const float4_t onei = float4_isplat(1);
const float4_t tmp4 = float4_isub(tmp3, onei);
const simd128_t zero = simd_zero();
const simd128_t mask = simd_cmpgt(f, zero);
const simd128_t onef = simd_splat(1.0f);
const simd128_t tmp0 = simd_and(mask, onef);
const simd128_t tmp1 = simd_ftoi(tmp0);
const simd128_t tmp2 = simd_xor(tmp1, reverse);
const simd128_t tmp3 = simd_sll(tmp2, 1);
const simd128_t onei = simd_isplat(1);
const simd128_t tmp4 = simd_isub(tmp3, onei);
BX_ALIGN_DECL_16(int32_t res[4]);
float4_st(&res, tmp4);
simd_st(&res, tmp4);
for (uint16_t jj = 0; jj < 2; ++jj)
{

View File

@ -7,5 +7,4 @@
void main()
{
gl_FragColor = vec4_splat(0.0);
}

View File

@ -11,9 +11,9 @@ $input v_view, v_normal
SAMPLERCUBE(s_texCube, 0);
SAMPLERCUBE(s_texCubeIrr, 1);
vec3 calcFresnel(vec3 _cspec, float _dot)
vec3 calcFresnel(vec3 _cspec, float _dot, float _strength)
{
return _cspec + (1.0 - _cspec)*pow(1.0 - _dot, 5.0);
return _cspec + (1.0 - _cspec)*pow(1.0 - _dot, 5.0) * _strength;
}
vec3 calcLambert(vec3 _cdiff, float _ndotl)
@ -50,35 +50,28 @@ void main()
float hdotv = clamp(dot(hh, vv), 0.0, 1.0);
// Material params.
vec3 albedo = u_rgbDiff.xyz;
float reflectivity = u_reflectivity;
float gloss = u_glossiness;
vec3 inAlbedo = u_rgbDiff.xyz;
float inReflectivity = u_reflectivity;
float inGloss = u_glossiness;
// Reflection.
vec3 refl;
if (0.0 == u_metalOrSpec) // Metalness workflow.
{
refl = mix(vec3_splat(0.04), albedo, reflectivity);
refl = mix(vec3_splat(0.04), inAlbedo, inReflectivity);
}
else // Specular workflow.
{
refl = u_rgbSpec.xyz * vec3_splat(reflectivity);
refl = u_rgbSpec.xyz * vec3_splat(inReflectivity);
}
vec3 dirF0 = calcFresnel(refl, hdotv);
vec3 envF0 = calcFresnel(refl, ndotv);
vec3 albedo = inAlbedo * (1.0 - inReflectivity);
vec3 dirFresnel = calcFresnel(refl, hdotv, inGloss);
vec3 envFresnel = calcFresnel(refl, ndotv, inGloss);
// Direct lighting.
vec3 dirSpec = dirF0;
vec3 dirDiff = albedo * 1.0-dirF0;
vec3 lambert = u_doDiffuse * calcLambert(dirDiff, ndotl);
vec3 blinn = u_doSpecular * calcBlinn(dirSpec, ndoth, ndotl, specPwr(gloss));
vec3 lambert = u_doDiffuse * calcLambert(albedo * (1.0 - dirFresnel), ndotl);
vec3 blinn = u_doSpecular * calcBlinn(dirFresnel, ndoth, ndotl, specPwr(inGloss));
vec3 direct = (lambert + blinn)*clight;
// Indirect lighting.
vec3 envSpec = envF0;
vec3 envDiff = albedo * 1.0-envF0;
// Note: Environment textures are filtered with cmft: https://github.com/dariomanesku/cmft
// Params used:
// --excludeBase true //!< First level mip is not filtered.
@ -86,7 +79,7 @@ void main()
// --glossScale 10 //!< Spec power scale. See: specPwr().
// --glossBias 2 //!< Spec power bias. See: specPwr().
// --edgeFixup warp //!< This must be used on DirectX9. When fileted with 'warp', fixCubeLookup() should be used.
float mip = 1.0 + 5.0*(1.0 - gloss); // Use mip levels [1..6] for radiance.
float mip = 1.0 + 5.0*(1.0 - inGloss); // Use mip levels [1..6] for radiance.
mat4 mtx;
mtx[0] = u_mtx0;
@ -98,9 +91,11 @@ void main()
vec3 cubeN = normalize(instMul(mtx, vec4(nn, 0.0)).xyz);
cubeR = fixCubeLookup(cubeR, mip, 256.0);
vec3 radiance = u_doDiffuseIbl * envSpec * toLinear(textureCubeLod(s_texCube, cubeR, mip).xyz);
vec3 irradiance = u_doSpecularIbl * envDiff * toLinear(textureCube(s_texCubeIrr, cubeN).xyz);
vec3 indirect = radiance + irradiance;
vec3 radiance = toLinear(textureCubeLod(s_texCube, cubeR, mip).xyz);
vec3 irradiance = toLinear(textureCube(s_texCubeIrr, cubeN).xyz);
vec3 envDiffuse = albedo * irradiance * u_doDiffuseIbl;
vec3 envSpecular = envFresnel * radiance * u_doSpecularIbl;
vec3 indirect = envDiffuse + envSpecular;
// Color.
vec3 color = direct + indirect;

View File

@ -731,7 +731,7 @@ int _main_(int _argc, char** _argv)
camera.envViewMtx(mtxEnvView);
float mtxEnvRot[16];
bx::mtxRotateY(mtxEnvRot, settings.m_envRotCurr);
bx::mtxMul(uniforms.m_mtx, mtxEnvView, mtxEnvRot);
bx::mtxMul(uniforms.m_mtx, mtxEnvView, mtxEnvRot); // Used for Skybox.
// Submit view 0.
bgfx::setTexture(0, s_texCube, lightProbes[currentLightProbe].m_tex);
@ -742,6 +742,7 @@ int _main_(int _argc, char** _argv)
bgfx::submit(0, programSky);
// Submit view 1.
memcpy(uniforms.m_mtx, mtxEnvRot, 16*sizeof(float)); // Used for IBL.
if (0 == settings.m_meshSelection)
{
// Submit bunny.
@ -749,6 +750,7 @@ int _main_(int _argc, char** _argv)
bx::mtxSRT(mtx, 1.0f, 1.0f, 1.0f, 0.0f, bx::pi, 0.0f, 0.0f, -0.80f, 0.0f);
bgfx::setTexture(0, s_texCube, lightProbes[currentLightProbe].m_tex);
bgfx::setTexture(1, s_texCubeIrr, lightProbes[currentLightProbe].m_texIrr);
uniforms.submit();
meshSubmit(meshBunny, 1, programMesh, mtx);
}
else

View File

@ -15,9 +15,9 @@ void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
float fov = 45.0;
float fov = radians(45.0);
float height = tan(fov*0.5);
float aspect = height*(4.0/3.0);
float aspect = height*(u_viewRect.z / u_viewRect.w);
vec2 tex = (2.0*a_texcoord0-1.0) * vec2(aspect, height);
mat4 mtx;

View File

@ -410,6 +410,14 @@ class ExampleOIT : public entry::AppI
| BGFX_STATE_MSAA
;
const uint64_t stateNoDepth = 0
| BGFX_STATE_CULL_CW
| BGFX_STATE_RGB_WRITE
| BGFX_STATE_ALPHA_WRITE
| BGFX_STATE_DEPTH_TEST_ALWAYS
| BGFX_STATE_MSAA
;
bgfx::ProgramHandle program = BGFX_INVALID_HANDLE;
switch (m_mode)
{
@ -428,7 +436,7 @@ class ExampleOIT : public entry::AppI
program = m_wbSeparatePass;
// Set render states.
bgfx::setState(state
bgfx::setState(stateNoDepth
| BGFX_STATE_BLEND_FUNC_SEPARATE(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ZERO, BGFX_STATE_BLEND_INV_SRC_ALPHA)
);
break;
@ -438,7 +446,7 @@ class ExampleOIT : public entry::AppI
program = m_wbPass;
// Set render states.
bgfx::setState(state
bgfx::setState(stateNoDepth
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
| BGFX_STATE_BLEND_INDEPENDENT
, 0

View File

@ -56,11 +56,11 @@ vec3 calcLight(int _idx, vec3 _wpos, vec3 _normal, vec3 _view)
float toClipSpaceDepth(float _depthTextureZ)
{
#if BGFX_SHADER_LANGUAGE_HLSL
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
#endif // BGFX_SHADER_LANGUAGE_HLSL
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
@ -76,9 +76,9 @@ void main()
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(v_texcoord0 * 2.0 - 1.0, depth);
#if BGFX_SHADER_LANGUAGE_HLSL
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
#endif // BGFX_SHADER_LANGUAGE_HLSL
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wpos = clipToWorld(u_mtx, clip);
vec3 view = mul(u_view, vec4(wpos, 0.0) ).xyz;

View File

@ -152,12 +152,12 @@ class DebugDrawApp : public entry::AppI
ddDraw(sphere);
ddSetWireframe(false);
ddSetColor(0xf0ffc0ff);
ddSetColor(0xc0ffc0ff);
sphere.m_center[0] = -2.0f;
ddSetLod(2);
ddDraw(sphere);
ddSetColor(0xc0f0ffff);
ddSetColor(0xa0f0ffff);
sphere.m_center[0] = -4.0f;
ddSetLod(1);
ddDraw(sphere);
@ -198,6 +198,12 @@ class DebugDrawApp : public entry::AppI
float to[3] = { -11.0f, 4.0f, 0.0f };
ddDrawCylinder(from, to, 0.5f );
}
{
float from[3] = { 0.0f, 7.0f, 0.0f };
float to[3] = { -6.0f, 7.0f, 0.0f };
ddDrawCylinder(from, to, 0.5f, true);
}
ddPop();
ddDrawOrb(-11.0f, 0.0f, 0.0f, 1.0f);

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -0,0 +1,16 @@
$input v_pos, v_view, v_normal, v_color0
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
uniform vec4 u_id;
void main()
{
gl_FragColor.xyz = u_id.xyz; // This is dumb, should use u8 texture
gl_FragColor.w = 1.0;
}

View File

@ -0,0 +1,44 @@
$input v_pos, v_view, v_normal, v_color0
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
{
float ndotl = dot(_normal, _lightDir);
vec3 reflected = _lightDir - 2.0*ndotl*_normal; // reflect(_lightDir, _normal);
float rdotv = dot(reflected, _viewDir);
return vec2(ndotl, rdotv);
}
float fresnel(float _ndotl, float _bias, float _pow)
{
float facing = (1.0 - _ndotl);
return max(_bias + (1.0 - _bias) * pow(facing, _pow), 0.0);
}
vec4 lit(float _ndotl, float _rdotv, float _m)
{
float diff = max(0.0, _ndotl);
float spec = step(0.0, _ndotl) * max(0.0, _rdotv * _m);
return vec4(1.0, diff, spec, 1.0);
}
void main()
{
vec3 lightDir = vec3(0.0, 0.0, -1.0);
vec3 normal = normalize(v_normal);
vec3 view = normalize(v_view);
vec2 bln = blinn(lightDir, normal, view);
vec4 lc = lit(bln.x, bln.y, 1.0);
float fres = fresnel(bln.x, 0.2, 5.0);
vec3 color = v_color0.xyz;
gl_FragColor.xyz = pow(vec3(0.07, 0.06, 0.08) + color*lc.y + fres*pow(lc.z, 128.0), vec3_splat(1.0/2.2) );
gl_FragColor.w = 1.0;
}

View File

@ -0,0 +1,18 @@
#
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
# License: http://www.opensource.org/licenses/BSD-2-Clause
#
BGFX_DIR=../..
RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
rebuild:
@make -s --no-print-directory TARGET=0 clean all
@make -s --no-print-directory TARGET=1 clean all
@make -s --no-print-directory TARGET=2 clean all
@make -s --no-print-directory TARGET=3 clean all
@make -s --no-print-directory TARGET=4 clean all
@make -s --no-print-directory TARGET=5 clean all

View File

@ -0,0 +1,423 @@
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "common.h"
#include "bgfx_utils.h"
#include "imgui/imgui.h"
#include <bx/rng.h>
#include <map>
#define RENDER_PASS_SHADING 0 // Default forward rendered geo with simple shading
#define RENDER_PASS_ID 1 // ID buffer for picking
#define RENDER_PASS_BLIT 2 // Blit GPU render target to CPU texture
#define ID_DIM 8 // Size of the ID buffer
class ExamplePicking : public entry::AppI
{
void init(int _argc, char** _argv) BX_OVERRIDE
{
Args args(_argc, _argv);
m_width = 1280;
m_height = 720;
m_debug = BGFX_DEBUG_TEXT;
m_reset = BGFX_RESET_VSYNC;
bgfx::init(args.m_type, args.m_pciId);
bgfx::reset(m_width, m_height, m_reset);
// Enable debug text.
bgfx::setDebug(m_debug);
// Set up screen clears
bgfx::setViewClear(RENDER_PASS_SHADING
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
, 0x303030ff
, 1.0f
, 0
);
// ID buffer clears to black, which represnts clicking on nothing (background)
bgfx::setViewClear(RENDER_PASS_ID
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
, 0x000000ff
, 1.0f
, 0
);
// Create uniforms
u_tint = bgfx::createUniform("u_tint", bgfx::UniformType::Vec4); // Tint for when you click on items
u_id = bgfx::createUniform("u_id", bgfx::UniformType::Vec4); // ID for drawing into ID buffer
// Create program from shaders.
m_shadingProgram = loadProgram("vs_picking_shaded", "fs_picking_shaded"); // Blinn shading
m_idProgram = loadProgram("vs_picking_shaded", "fs_picking_id"); // Shader for drawing into ID buffer
static const char* meshPaths[] =
{
"meshes/orb.bin",
"meshes/column.bin",
"meshes/bunny.bin",
"meshes/cube.bin",
"meshes/tree.bin",
"meshes/hollowcube.bin",
};
static const float meshScale[] =
{
0.5f,
0.05f,
0.5f,
0.25f,
0.05f,
0.05f,
};
m_highlighted = UINT32_MAX;
m_reading = 0;
m_currFrame = UINT32_MAX;
m_fov = 3.0f;
m_cameraSpin = false;
bx::RngMwc mwc; // Random number generator
for (uint32_t ii = 0; ii < 12; ++ii)
{
m_meshes[ii] = meshLoad(meshPaths[ii % BX_COUNTOF(meshPaths)]);
m_meshScale[ii] = meshScale[ii % BX_COUNTOF(meshPaths)];
// For the sake of this example, we'll give each mesh a random color, so the debug output looks colorful.
// In an actual app, you'd probably just want to count starting from 1
uint32_t rr = mwc.gen() % 256;
uint32_t gg = mwc.gen() % 256;
uint32_t bb = mwc.gen() % 256;
m_idsF[ii][0] = rr / 255.0f;
m_idsF[ii][1] = gg / 255.0f;
m_idsF[ii][2] = bb / 255.0f;
m_idsF[ii][3] = 1.0f;
m_idsU[ii] = rr + (gg << 8) + (bb << 16) + (255u << 24);
}
m_timeOffset = bx::getHPCounter();
// Set up ID buffer, which has a color target and depth buffer
m_pickingRT = bgfx::createTexture2D(ID_DIM, ID_DIM, 1, bgfx::TextureFormat::RGBA8, 0
| BGFX_TEXTURE_RT
| BGFX_TEXTURE_MIN_POINT
| BGFX_TEXTURE_MAG_POINT
| BGFX_TEXTURE_MIP_POINT
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP
);
m_pickingRTDepth = bgfx::createTexture2D(ID_DIM, ID_DIM, 1, bgfx::TextureFormat::D24S8, 0
| BGFX_TEXTURE_RT
| BGFX_TEXTURE_MIN_POINT
| BGFX_TEXTURE_MAG_POINT
| BGFX_TEXTURE_MIP_POINT
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP
);
// CPU texture for blitting to and reading ID buffer so we can see what was clicked on.
// Impossible to read directly from a render target, you *must* blit to a CPU texture
// first. Algorithm Overview: Render on GPU -> Blit to CPU texture -> Read from CPU
// texture.
m_blitTex = bgfx::createTexture2D(ID_DIM, ID_DIM, 1, bgfx::TextureFormat::RGBA8, 0
| BGFX_TEXTURE_BLIT_DST
| BGFX_TEXTURE_READ_BACK
| BGFX_TEXTURE_MIN_POINT
| BGFX_TEXTURE_MAG_POINT
| BGFX_TEXTURE_MIP_POINT
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP
);
bgfx::TextureHandle rt[2] =
{
m_pickingRT,
m_pickingRTDepth
};
m_pickingFB = bgfx::createFrameBuffer(BX_COUNTOF(rt), rt, true);
imguiCreate();
}
int shutdown() BX_OVERRIDE
{
for (uint32_t ii = 0; ii < 12; ++ii)
{
meshUnload(m_meshes[ii]);
}
// Cleanup.
bgfx::destroyProgram(m_shadingProgram);
bgfx::destroyProgram(m_idProgram);
bgfx::destroyUniform(u_tint);
bgfx::destroyUniform(u_id);
bgfx::destroyFrameBuffer(m_pickingFB);
bgfx::destroyTexture(m_pickingRT);
bgfx::destroyTexture(m_pickingRTDepth);
bgfx::destroyTexture(m_blitTex);
imguiDestroy();
// Shutdown bgfx.
bgfx::shutdown();
return 0;
}
bool update() BX_OVERRIDE
{
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
bgfx::setViewFrameBuffer(RENDER_PASS_ID, m_pickingFB);
int64_t now = bx::getHPCounter();
static int64_t last = now;
const int64_t frameTime = now - last;
last = now;
const double freq = double(bx::getHPFrequency());
const double toMs = 1000.0 / freq;
float time = (float)( (bx::getHPCounter() - m_timeOffset) / double(bx::getHPFrequency() ) );
// Use debug font to print information about this example.
bgfx::dbgTextClear();
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/30-picking");
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Mouse picking via GPU texture readback.");
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
// Set up matrices for basic forward renderer
const float camSpeed = 0.25;
float cameraSpin = (float)m_cameraSpin;
float eyeDist = 2.5f;
float eye[3] =
{
-eyeDist * bx::fsin(time*cameraSpin*camSpeed),
0.0f,
-eyeDist * bx::fcos(time*cameraSpin*camSpeed),
};
float at[3] = { 0.0f, 0.0f, 0.0f };
float view[16];
bx::mtxLookAt(view, eye, at);
float proj[16];
bx::mtxProj(proj, 60.0f, float(m_width) / float(m_height), 0.1f, 100.0f);
// Set up view rect and transform for the shaded pass
bgfx::setViewRect(RENDER_PASS_SHADING, 0, 0, uint16_t(m_width), uint16_t(m_height) );
bgfx::setViewTransform(RENDER_PASS_SHADING, view, proj);
// Set up picking pass
float pickView[16];
float pickAt[4]; // Need to inversly project the mouse pointer to determin what we're looking at
float pickEye[3] = { eye[0], eye[1], eye[2] }; // Eye is same location as before
float viewProj[16];
bx::mtxMul(viewProj, view, proj);
float invViewProj[16];
bx::mtxInverse(invViewProj, viewProj);
// Mouse coord in NDC
float mouseXNDC = (m_mouseState.m_mx / (float)m_width) * 2.0f - 1.0f;
float mouseYNDC = ((m_height - m_mouseState.m_my) / (float)m_height) * 2.0f - 1.0f;
float mousePosNDC[4] = { mouseXNDC, mouseYNDC, 0, 1.0f };
// Unproject and perspective divide
bx::vec4MulMtx(pickAt, mousePosNDC, invViewProj);
pickAt[3] = 1.0f / pickAt[3];
pickAt[0] *= pickAt[3];
pickAt[1] *= pickAt[3];
pickAt[2] *= pickAt[3];
// Look at our unprojected point
bx::mtxLookAt(pickView, pickEye, pickAt);
float pickProj[16];
// Tight FOV is best for picking
bx::mtxProj(pickProj, m_fov, 1, 0.1f, 100.0f);
// View rect and transforms for picking pass
bgfx::setViewRect(RENDER_PASS_ID, 0, 0, ID_DIM, ID_DIM);
bgfx::setViewTransform(RENDER_PASS_ID, pickView, pickProj);
// Now that our passes are set up, we can finally draw each mesh
// Picking highlights a mesh so we'll set up this tint color
const float tintBasic[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
const float tintHighlighted[4] = { 0.3f, 0.3f, 2.0f, 1.0f };
for (uint32_t mesh = 0; mesh < 12; ++mesh)
{
const float scale = m_meshScale[mesh];
// Set up transform matrix for each mesh
float mtx[16];
bx::mtxSRT(mtx
, scale, scale, scale
, 0.0f
, time*0.37f*(mesh % 2 ? 1.0f : -1.0f)
, 0.0f
, (mesh % 4) - 1.5f
, (mesh / 4) - 1.25f
, 0.0f
);
// Submit mesh to both of our render passes
// Set uniform based on if this is the highlighted mesh
bgfx::setUniform(u_tint
, mesh == m_highlighted
? tintHighlighted
: tintBasic
);
meshSubmit(m_meshes[mesh], RENDER_PASS_SHADING, m_shadingProgram, mtx);
// Submit ID pass based on mesh ID
bgfx::setUniform(u_id, m_idsF[mesh]);
meshSubmit(m_meshes[mesh], RENDER_PASS_ID, m_idProgram, mtx);
}
// If the user previously clicked, and we're done reading data from GPU, look at ID buffer on CPU
// Whatever mesh has the most pixels in the ID buffer is the one the user clicked on.
if (m_reading == m_currFrame)
{
m_reading = 0;
std::map<uint32_t, uint32_t> ids; // This contains all the IDs found in the buffer
uint32_t maxAmount = 0;
for (uint8_t *x = m_blitData; x < m_blitData + ID_DIM * ID_DIM * 4;)
{
uint8_t rr = *x++;
uint8_t gg = *x++;
uint8_t bb = *x++;
uint8_t aa = *x++;
const bgfx::Caps* caps = bgfx::getCaps();
if (bgfx::RendererType::Direct3D9 == caps->rendererType)
{
// Comes back as BGRA
uint8_t temp = rr;
rr = bb;
bb = temp;
}
if (0 == (rr|gg|bb) ) // Skip background
{
continue;
}
uint32_t hashKey = rr + (gg << 8) + (bb << 16) + (aa << 24);
std::map<uint32_t, uint32_t>::iterator mapIter = ids.find(hashKey);
uint32_t amount = 1;
if (mapIter != ids.end() )
{
amount = mapIter->second + 1;
}
ids[hashKey] = amount; // Amount of times this ID (color) has been clicked on in buffer
maxAmount = maxAmount > amount
? maxAmount
: amount
;
}
uint32_t idKey = 0;
m_highlighted = UINT32_MAX;
if (maxAmount)
{
for (std::map<uint32_t, uint32_t>::iterator mapIter = ids.begin(); mapIter != ids.end(); mapIter++)
{
if (mapIter->second == maxAmount)
{
idKey = mapIter->first;
break;
}
}
for (uint32_t ii = 0; ii < 12; ++ii)
{
if (m_idsU[ii] == idKey)
{
m_highlighted = ii;
break;
}
}
}
}
// Start a new readback?
if (!m_reading
&& m_mouseState.m_buttons[entry::MouseButton::Left])
{
// Blit and read
bgfx::blit(RENDER_PASS_BLIT, m_blitTex, 0, 0, m_pickingRT);
m_reading = bgfx::readTexture(m_blitTex, m_blitData);
}
// Draw UI
imguiBeginFrame(m_mouseState.m_mx
, m_mouseState.m_my
, (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
| (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
| (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
, m_mouseState.m_mz
, m_width
, m_height
);
imguiBeginArea("Picking Render Target:", 10, 100, 300, 400);
imguiImage(m_pickingRT, 1.0f, 1.0f, 1.0f);
imguiSlider("FOV", m_fov, 1.0f, 60.0f, 1.0f);
if (imguiCheck("Spin Camera", m_cameraSpin))
{
m_cameraSpin = !m_cameraSpin;
}
imguiEndArea();
imguiEndFrame();
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
m_currFrame = bgfx::frame();
return true;
}
return false;
}
uint32_t m_width;
uint32_t m_height;
uint32_t m_debug;
uint32_t m_reset;
int64_t m_timeOffset;
entry::MouseState m_mouseState;
Mesh* m_meshes[12];
float m_meshScale[12];
float m_idsF[12][4];
uint32_t m_idsU[12];
uint32_t m_highlighted;
// Resource handles
bgfx::ProgramHandle m_shadingProgram;
bgfx::ProgramHandle m_idProgram;
bgfx::UniformHandle u_tint;
bgfx::UniformHandle u_id;
bgfx::TextureHandle m_pickingRT;
bgfx::TextureHandle m_pickingRTDepth;
bgfx::TextureHandle m_blitTex;
bgfx::FrameBufferHandle m_pickingFB;
uint8_t m_blitData[ID_DIM*ID_DIM * 4]; // Read blit into this
uint32_t m_reading;
uint32_t m_currFrame;
float m_fov;
bool m_cameraSpin;
};
ENTRY_IMPLEMENT_MAIN(ExamplePicking);

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

View File

@ -0,0 +1,10 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec3 v_pos : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
vec3 v_view : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;
vec2 a_texcoord0 : TEXCOORD0;
vec3 a_normal : NORMAL;

View File

@ -0,0 +1,25 @@
$input a_position, a_normal
$output v_pos, v_view, v_normal, v_color0
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
uniform vec4 u_tint;
void main()
{
vec3 pos = a_position;
vec3 normal = a_normal.xyz*2.0 - 1.0;
gl_Position = mul(u_modelViewProj, vec4(pos, 1.0) );
v_pos = gl_Position.xyz;
v_view = mul(u_modelView, vec4(pos, 1.0) ).xyz;
v_normal = mul(u_modelView, vec4(normal, 0.0) ).xyz;
v_color0 = u_tint*vec4(0.8, 0.8, 0.8, 1.0);
}

View File

@ -0,0 +1,131 @@
$input v_texcoord0
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
SAMPLER2D(s_normal, 0);
SAMPLER2D(s_color, 1);
SAMPLER2D(s_light, 2);
SAMPLER2D(s_depth, 3);
SAMPLER2DSHADOW(s_shadowMap, 4);
// Single directional light for entire scene
uniform vec4 u_lightDir;
uniform mat4 u_invMvp;
uniform mat4 u_lightMtx;
uniform vec4 u_shadowDimsInv;
uniform vec4 u_rsmAmount;
float hardShadow(sampler2DShadow _sampler, vec4 _shadowCoord, float _bias)
{
vec2 texCoord = _shadowCoord.xy;
return shadow2D(_sampler, vec3(texCoord.xy, _shadowCoord.z-_bias) );
}
float PCF(sampler2DShadow _sampler, vec4 _shadowCoord, float _bias, vec2 _texelSize)
{
vec2 texCoord = _shadowCoord.xy;
bool outside = any(greaterThan(texCoord, vec2_splat(1.0)))
|| any(lessThan (texCoord, vec2_splat(0.0)))
;
if (outside)
{
return 1.0;
}
float result = 0.0;
vec2 offset = _texelSize * _shadowCoord.w;
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -1.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 1.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -1.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 1.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -1.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 1.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -1.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 0.5) * offset, 0.0, 0.0), _bias);
result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 1.5) * offset, 0.0, 0.0), _bias);
return result / 16.0;
}
float toClipSpaceDepth(float _depthTextureZ)
{
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
{
vec4 wpos = mul(_invViewProj, vec4(_clipPos, 1.0) );
return wpos.xyz / wpos.w;
}
void main()
{
vec3 n = texture2D(s_normal, v_texcoord0).xyz;
// Expand out normal
n = n*2.0+-1.0;
vec3 l = u_lightDir.xyz;//normalize(vec3(-0.8,0.75,-1.0));
float dirLightIntensity = 1.0;
float dirLight = max(0.0,dot(n,l)) * dirLightIntensity;
// Apply shadow map
// Get world position so we can transform it into light space, to look into shadow map
vec2 texCoord = v_texcoord0.xy;
float deviceDepth = texture2D(s_depth, texCoord).x;
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(texCoord * 2.0 - 1.0, depth);
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wpos = clipToWorld(u_invMvp, clip);
const float shadowMapOffset = 0.003;
vec3 posOffset = wpos + n.xyz * shadowMapOffset;
vec4 shadowCoord = mul(u_lightMtx, vec4(posOffset, 1.0) );
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
shadowCoord.y *= -1.0;
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
float shadowMapBias = 0.001;
vec2 texelSize = vec2_splat(u_shadowDimsInv.x);
shadowCoord.xy /= shadowCoord.w;
shadowCoord.xy = shadowCoord.xy*0.5+0.5;
float visibility = PCF(s_shadowMap, shadowCoord, shadowMapBias, texelSize);
dirLight *= visibility;
// Light from light buffer
vec3 albedo = texture2D(s_color, v_texcoord0).xyz;
vec3 lightBuffer = texture2D(s_light, v_texcoord0).xyz;
gl_FragColor.xyz = mix(dirLight * albedo, lightBuffer * albedo, u_rsmAmount.x);
gl_FragColor.w = 1.0;
}

View File

@ -0,0 +1,22 @@
$input v_normal
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
uniform vec4 u_tint;
void main()
{
vec3 normalWorldSpace = v_normal;
// Write normal
gl_FragData[0].xyz = normalWorldSpace.xyz; // Normal is already compressed to [0,1] so can fit in gbuffer
gl_FragData[0].w = 0.0;
// Write color
gl_FragData[1] = u_tint;
}

View File

@ -0,0 +1,67 @@
$input v_lightCenterScale, v_color0
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
SAMPLER2D(s_normal, 0); // Normal output from gbuffer
SAMPLER2D(s_depth, 1); // Depth output from gbuffer
uniform mat4 u_invMvp;
float toClipSpaceDepth(float _depthTextureZ)
{
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
{
vec4 wpos = mul(_invViewProj, vec4(_clipPos, 1.0) );
return wpos.xyz / wpos.w;
}
void main()
{
#if BGFX_SHADER_LANGUAGE_HLSL && (BGFX_SHADER_LANGUAGE_HLSL < 4)
vec2 texCoord = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * vec2_splat(0.5);
#else
vec2 texCoord = gl_FragCoord.xy * u_viewTexel.xy;
#endif
// Get world position
float deviceDepth = texture2D(s_depth, texCoord).x;
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(texCoord * 2.0 - 1.0, depth);
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wpos = clipToWorld(u_invMvp, clip);
// Get normal from its map, and decompress
vec3 n = texture2D(s_normal, texCoord).xyz*2.0-1.0;
// Do lighting
vec3 pointToLight = v_lightCenterScale.xyz-wpos;
float lightLen = sqrt(dot(pointToLight, pointToLight));
float lightFalloff;
if (lightLen > v_lightCenterScale.w)
lightFalloff = 0.0;
else
lightFalloff = 1.0-(lightLen/v_lightCenterScale.w); // Linear falloff for light (could use dist sq if you want)
vec3 l = normalize(pointToLight)*lightFalloff;
gl_FragColor.xyz = v_color0.xyz * max(0.0, dot(n,l));
gl_FragColor.w = 1.0;
}

View File

@ -0,0 +1,22 @@
$input v_normal
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
uniform vec4 u_tint;
void main()
{
#if BGFX_SHADER_LANGUAGE_HLSL && (BGFX_SHADER_LANGUAGE_HLSL < 4)
vec2 texCoord = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * vec2_splat(0.5);
#else
vec2 texCoord = gl_FragCoord.xy * u_viewTexel.xy;
#endif
gl_FragData[0].xyz = u_tint.xyz; // Color of light sphere
gl_FragData[0].w = -v_normal.z; // Radius of light sphere
}

18
3rdparty/bgfx/examples/31-rsm/makefile vendored Normal file
View File

@ -0,0 +1,18 @@
#
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
# License: http://www.opensource.org/licenses/BSD-2-Clause
#
BGFX_DIR=../..
RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
rebuild:
@make -s --no-print-directory TARGET=0 clean all
@make -s --no-print-directory TARGET=1 clean all
@make -s --no-print-directory TARGET=2 clean all
@make -s --no-print-directory TARGET=3 clean all
@make -s --no-print-directory TARGET=4 clean all
@make -s --no-print-directory TARGET=5 clean all

View File

@ -0,0 +1,745 @@
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "common.h"
#include "camera.h"
#include "bgfx_utils.h"
#include "imgui/imgui.h"
#include <bx/rng.h>
/*
* Intro
* =====
*
* RSM (reflective shadow map) is a technique for global illumination.
* It is similar to shadow map. It piggybacks on the shadow map, in fact.
*
* RSM is compatible with any type of lighting which can handle handle
* a lot of point lights. This sample happens to use a deferred renderer,
* but other types would work.
*
* Overview:
*
* - Draw into G-Buffer
* - Draw Shadow Map (with RSM piggybacked on)
* - Populate light buffer
* - Deferred "combine" pass.
*
* Details
* =======
*
* ## G-Buffer
*
* Typical G-Buffer with normals, color, depth.
*
* ## RSM
*
* A typical shadow map, except it also outputs to a "RSM" buffer.
* The RSM contains the color of the item drawn, as well as a scalar value which represents
* how much light would bounce off of the surface if it were hit with light from the origin
* of the shadow map.
*
* ## Light Buffer
*
* We draw a lot of spheres into the light buffer. These spheres are called VPL (virtual
* point lights). VPLs represent bounced light, and let us eliminate the classic "ambient"
* term. Instead of us supplying their world space position in a transform matrix,
* VPLs gain their position from the shadow map from step 2, using an unprojection. They gain
* their color from the RSM. You could also store their position in a buffer while drawing shadows,
* I'm just using depth to keep the sample smaller.
*
* ## Deferred combine
*
* Typical combine used in almost any sort of deferred renderer.
*
* References
* ==========
*
* http: *www.bpeers.com/blog/?itemid=517
*
*/
// Render passes
#define RENDER_PASS_GBUFFER 0 // GBuffer for normals and albedo
#define RENDER_PASS_SHADOW_MAP 1 // Draw into the shadow map (RSM and regular shadow map at same time)
#define RENDER_PASS_LIGHT_BUFFER 2 // Light buffer for point lights
#define RENDER_PASS_COMBINE 3 // Directional light and final result
// Gbuffer has multiple render targets
#define GBUFFER_RT_NORMAL 0
#define GBUFFER_RT_COLOR 1
#define GBUFFER_RT_DEPTH 2
// Shadow map has multiple render targets
#define SHADOW_RT_RSM 0 // In this algorithm, shadows write lighting info as well.
#define SHADOW_RT_DEPTH 1 // Shadow maps always write a depth
// Random meshes we draw
#define MODEL_COUNT 222 // In this demo, a model is a mesh plus a transform and a color
#define SHADOW_MAP_DIM 512
#define LIGHT_DIST 10.0f
static const char * s_meshPaths[] =
{
"meshes/cube.bin",
"meshes/orb.bin",
"meshes/column.bin",
"meshes/bunny.bin",
"meshes/tree.bin",
"meshes/hollowcube.bin"
};
static const float s_meshScale[] =
{
0.25f,
0.5f,
0.05f,
0.5f,
0.05f,
0.05f
};
// Vertex decl for our screen space quad (used in deferred rendering)
struct PosTexCoord0Vertex
{
float m_x;
float m_y;
float m_z;
float m_u;
float m_v;
static void init()
{
ms_decl
.begin()
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
.end();
}
static bgfx::VertexDecl ms_decl;
};
bgfx::VertexDecl PosTexCoord0Vertex::ms_decl;
// Utility function to draw a screen space quad for deferred rendering
void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f)
{
if (bgfx::checkAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) )
{
bgfx::TransientVertexBuffer vb;
bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl);
PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data;
const float minx = -_width;
const float maxx = _width;
const float miny = 0.0f;
const float maxy = _height*2.0f;
const float texelHalfW = _texelHalf/_textureWidth;
const float texelHalfH = _texelHalf/_textureHeight;
const float minu = -1.0f + texelHalfW;
const float maxu = 1.0f + texelHalfH;
const float zz = 0.0f;
float minv = texelHalfH;
float maxv = 2.0f + texelHalfH;
if (_originBottomLeft)
{
float temp = minv;
minv = maxv;
maxv = temp;
minv -= 1.0f;
maxv -= 1.0f;
}
vertex[0].m_x = minx;
vertex[0].m_y = miny;
vertex[0].m_z = zz;
vertex[0].m_u = minu;
vertex[0].m_v = minv;
vertex[1].m_x = maxx;
vertex[1].m_y = miny;
vertex[1].m_z = zz;
vertex[1].m_u = maxu;
vertex[1].m_v = minv;
vertex[2].m_x = maxx;
vertex[2].m_y = maxy;
vertex[2].m_z = zz;
vertex[2].m_u = maxu;
vertex[2].m_v = maxv;
bgfx::setVertexBuffer(&vb);
}
}
class ExampleRSM : public entry::AppI
{
public:
ExampleRSM()
: m_reading(0)
, m_currFrame(UINT32_MAX)
, m_cameraSpin(false)
, m_lightElevation(35.0f)
, m_lightAzimuth(215.0f)
, m_rsmAmount(0.25f)
, m_vplRadius(3.0f)
, m_texelHalf(0.0f)
{
}
void init(int _argc, char** _argv) BX_OVERRIDE
{
Args args(_argc, _argv);
m_width = 1280;
m_height = 720;
m_debug = BGFX_DEBUG_TEXT;
m_reset = BGFX_RESET_VSYNC;
bgfx::init(args.m_type, args.m_pciId);
bgfx::reset(m_width, m_height, m_reset);
// Enable debug text.
bgfx::setDebug(m_debug);
// Labeling for renderdoc captures, etc
bgfx::setViewName(RENDER_PASS_GBUFFER, "gbuffer" );
bgfx::setViewName(RENDER_PASS_SHADOW_MAP, "shadow map" );
bgfx::setViewName(RENDER_PASS_LIGHT_BUFFER, "light buffer");
bgfx::setViewName(RENDER_PASS_COMBINE, "post combine");
// Set up screen clears
bgfx::setViewClear(RENDER_PASS_GBUFFER
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0
, 1.0f
, 0
);
bgfx::setViewClear(RENDER_PASS_LIGHT_BUFFER
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0
, 1.0f
, 0
);
bgfx::setViewClear(RENDER_PASS_SHADOW_MAP
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0
, 1.0f
, 0
);
// Create uniforms
u_tint = bgfx::createUniform("u_tint", bgfx::UniformType::Vec4); // Tint for when you click on items
u_lightDir = bgfx::createUniform("u_lightDir", bgfx::UniformType::Vec4); // Single directional light for entire scene
u_sphereInfo = bgfx::createUniform("u_sphereInfo", bgfx::UniformType::Vec4); // Info for RSM
u_invMvp = bgfx::createUniform("u_invMvp", bgfx::UniformType::Mat4); // Matrix needed in light buffer
u_invMvpShadow = bgfx::createUniform("u_invMvpShadow", bgfx::UniformType::Mat4); // Matrix needed in light buffer
u_lightMtx = bgfx::createUniform("u_lightMtx", bgfx::UniformType::Mat4); // Matrix needed to use shadow map (world to shadow space)
u_shadowDimsInv = bgfx::createUniform("u_shadowDimsInv", bgfx::UniformType::Vec4); // Used in PCF
u_rsmAmount = bgfx::createUniform("u_rsmAmount", bgfx::UniformType::Vec4); // How much RSM to use vs directional light
// Create texture sampler uniforms (used when we bind textures)
s_normal = bgfx::createUniform("s_normal", bgfx::UniformType::Int1); // Normal gbuffer
s_depth = bgfx::createUniform("s_depth", bgfx::UniformType::Int1); // Normal gbuffer
s_color = bgfx::createUniform("s_color", bgfx::UniformType::Int1); // Color (albedo) gbuffer
s_light = bgfx::createUniform("s_light", bgfx::UniformType::Int1); // Light buffer
s_shadowMap = bgfx::createUniform("s_shadowMap", bgfx::UniformType::Int1); // Shadow map
s_rsm = bgfx::createUniform("s_rsm", bgfx::UniformType::Int1); // Reflective shadow map
// Create program from shaders.
m_gbufferProgram = loadProgram("vs_rsm_gbuffer", "fs_rsm_gbuffer"); // Gbuffer
m_shadowProgram = loadProgram("vs_rsm_shadow", "fs_rsm_shadow" ); // Drawing shadow map
m_lightProgram = loadProgram("vs_rsm_lbuffer", "fs_rsm_lbuffer"); // Light buffer
m_combineProgram = loadProgram("vs_rsm_combine", "fs_rsm_combine"); // Combiner
// Load some meshes
for (uint32_t ii = 0; ii < BX_COUNTOF(s_meshPaths); ++ii)
{
m_meshes[ii] = meshLoad(s_meshPaths[ii]);
}
// Randomly create some models
bx::RngMwc mwc; // Random number generator
for (uint32_t ii = 0; ii < BX_COUNTOF(m_models); ++ii)
{
Model& model = m_models[ii];
uint32_t rr = mwc.gen() % 256;
uint32_t gg = mwc.gen() % 256;
uint32_t bb = mwc.gen() % 256;
model.mesh = 1+mwc.gen()%(BX_COUNTOF(s_meshPaths)-1);
model.color[0] = rr/255.0f;
model.color[1] = gg/255.0f;
model.color[2] = bb/255.0f;
model.color[3] = 1.0f;
model.position[0] = (((mwc.gen() % 256)) - 128.0f)/20.0f;
model.position[1] = 0;
model.position[2] = (((mwc.gen() % 256)) - 128.0f)/20.0f;
}
// Load ground. We'll just use the cube since I don't have a ground model right now
m_ground = meshLoad("meshes/cube.bin");
// Light sphere
m_lightSphere = meshLoad("meshes/unit_sphere.bin");
const uint32_t samplerFlags = 0
| BGFX_TEXTURE_RT
| BGFX_TEXTURE_MIN_POINT
| BGFX_TEXTURE_MAG_POINT
| BGFX_TEXTURE_MIP_POINT
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP
;
// Make gbuffer and related textures
m_gbufferTex[GBUFFER_RT_NORMAL] = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
m_gbufferTex[GBUFFER_RT_COLOR] = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
m_gbufferTex[GBUFFER_RT_DEPTH] = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, 1, bgfx::TextureFormat::D24, samplerFlags);
m_gbuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_gbufferTex), m_gbufferTex, true);
// Make light buffer
m_lightBufferTex = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
bgfx::TextureHandle lightBufferRTs[] = {
m_lightBufferTex
};
m_lightBuffer = bgfx::createFrameBuffer(BX_COUNTOF(lightBufferRTs), lightBufferRTs, true);
// Make shadow buffer
const uint32_t rsmFlags = 0
| BGFX_TEXTURE_RT
| BGFX_TEXTURE_MIN_POINT
| BGFX_TEXTURE_MAG_POINT
| BGFX_TEXTURE_MIP_POINT
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP
;
// Reflective shadow map
m_shadowBufferTex[SHADOW_RT_RSM] = bgfx::createTexture2D(
SHADOW_MAP_DIM
, SHADOW_MAP_DIM
, 1
, bgfx::TextureFormat::BGRA8,
rsmFlags
);
// Typical shadow map
m_shadowBufferTex[SHADOW_RT_DEPTH] = bgfx::createTexture2D(
SHADOW_MAP_DIM
, SHADOW_MAP_DIM
, 1
, bgfx::TextureFormat::D16,
BGFX_TEXTURE_RT/* | BGFX_TEXTURE_COMPARE_LEQUAL*/
); // Note I'm not setting BGFX_TEXTURE_COMPARE_LEQUAL. Why?
// Normally a PCF shadow map such as this requires a compare. However, this sample also
// reads from this texture in the lighting pass, and only uses the PCF capabilites in the
// combine pass, so the flag is disabled by default.
m_shadowBuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_shadowBufferTex), m_shadowBufferTex, true);
// Vertex decl
PosTexCoord0Vertex::init();
// Init camera
cameraCreate();
float camPos[] = {0.0f, 1.5f, 0.0f};
cameraSetPosition(camPos);
cameraSetVerticalAngle(-0.3f);
// Init directional light
updateLightDir();
// Get renderer capabilities info.
m_caps = bgfx::getCaps();
const bgfx::RendererType::Enum renderer = bgfx::getRendererType();
m_texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f;
imguiCreate();
}
int shutdown() BX_OVERRIDE
{
for (uint32_t ii = 0; ii < BX_COUNTOF(s_meshPaths); ++ii)
{
meshUnload(m_meshes[ii]);
}
meshUnload(m_ground);
meshUnload(m_lightSphere);
// Cleanup.
bgfx::destroyProgram(m_gbufferProgram);
bgfx::destroyProgram(m_lightProgram);
bgfx::destroyProgram(m_combineProgram);
bgfx::destroyProgram(m_shadowProgram);
bgfx::destroyUniform(u_tint);
bgfx::destroyUniform(u_lightDir);
bgfx::destroyUniform(u_sphereInfo);
bgfx::destroyUniform(u_invMvp);
bgfx::destroyUniform(u_invMvpShadow);
bgfx::destroyUniform(u_lightMtx);
bgfx::destroyUniform(u_shadowDimsInv);
bgfx::destroyUniform(u_rsmAmount);
bgfx::destroyUniform(s_normal);
bgfx::destroyUniform(s_depth);
bgfx::destroyUniform(s_light);
bgfx::destroyUniform(s_color);
bgfx::destroyUniform(s_shadowMap);
bgfx::destroyUniform(s_rsm);
bgfx::destroyFrameBuffer(m_gbuffer);
bgfx::destroyFrameBuffer(m_lightBuffer);
bgfx::destroyFrameBuffer(m_shadowBuffer);
for (uint32_t ii = 0; ii < BX_COUNTOF(m_gbufferTex); ++ii)
{
bgfx::destroyTexture(m_gbufferTex[ii]);
}
bgfx::destroyTexture(m_lightBufferTex);
for (uint32_t ii = 0; ii < BX_COUNTOF(m_shadowBufferTex); ++ii)
{
bgfx::destroyTexture(m_shadowBufferTex[ii]);
}
cameraDestroy();
imguiDestroy();
// Shutdown bgfx.
bgfx::shutdown();
return 0;
}
bool update() BX_OVERRIDE
{
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
// Update frame timer
int64_t now = bx::getHPCounter();
static int64_t last = now;
const int64_t frameTime = now - last;
last = now;
const double freq = double(bx::getHPFrequency());
const double toMs = 1000.0 / freq;
const float deltaTime = float(frameTime/freq);
// Use debug font to print information about this example.
bgfx::dbgTextClear();
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/31-rsm");
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Global Illumination with Reflective Shadow Map.");
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
// Update camera
cameraUpdate(deltaTime*0.15f, m_mouseState);
// Set up matrices for gbuffer
float view[16];
cameraGetViewMtx(view);
float proj[16];
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
bgfx::setViewRect(RENDER_PASS_GBUFFER, 0, 0, uint16_t(m_width), uint16_t(m_height));
bgfx::setViewTransform(RENDER_PASS_GBUFFER, view, proj);
// Make sure when we draw it goes into gbuffer and not backbuffer
bgfx::setViewFrameBuffer(RENDER_PASS_GBUFFER, m_gbuffer);
// Draw everything into g-buffer
drawAllModels(RENDER_PASS_GBUFFER, m_gbufferProgram);
// Draw shadow map
// Set up transforms for shadow map
float smView[16], smProj[16], lightEye[3], lightAt[3];
lightEye[0] = m_lightDir[0]*LIGHT_DIST;
lightEye[1] = m_lightDir[1]*LIGHT_DIST;
lightEye[2] = m_lightDir[2]*LIGHT_DIST;
lightAt[0] = 0.0f;
lightAt[1] = 0.0f;
lightAt[2] = 0.0f;
bx::mtxLookAt(smView, lightEye, lightAt);
const float area = 10.0f;
bgfx::RendererType::Enum renderer = bgfx::getRendererType();
bool flipV = false
|| renderer == bgfx::RendererType::OpenGL
|| renderer == bgfx::RendererType::OpenGLES
;
bx::mtxOrtho(smProj, -area, area, -area, area, -100.0f, 100.0f, 0.0f, flipV);
bgfx::setViewTransform(RENDER_PASS_SHADOW_MAP, smView, smProj);
bgfx::setViewFrameBuffer(RENDER_PASS_SHADOW_MAP, m_shadowBuffer);
bgfx::setViewRect(RENDER_PASS_SHADOW_MAP, 0, 0, SHADOW_MAP_DIM, SHADOW_MAP_DIM);
drawAllModels(RENDER_PASS_SHADOW_MAP, m_shadowProgram);
// Next draw light buffer
// Set up matrices for light buffer
bgfx::setViewRect(RENDER_PASS_LIGHT_BUFFER, 0, 0, uint16_t(m_width), uint16_t(m_height));
bgfx::setViewTransform(RENDER_PASS_LIGHT_BUFFER, view, proj); // Notice, same view and proj as gbuffer
// Set drawing into light buffer
bgfx::setViewFrameBuffer(RENDER_PASS_LIGHT_BUFFER, m_lightBuffer);
// Inverse view projection is needed in shader so set that up
float vp[16], invMvp[16];
bx::mtxMul(vp, view, proj);
bx::mtxInverse(invMvp, vp);
// Light matrix used in combine pass and inverse used in light pass
float lightMtx[16]; // World space to light space (shadow map space)
bx::mtxMul(lightMtx, smView, smProj);
float invMvpShadow[16];
bx::mtxInverse(invMvpShadow, lightMtx);
// Draw some lights (these should really be instanced but for this example they aren't...)
const unsigned MAX_SPHERE = 32;
for (uint32_t i = 0; i < MAX_SPHERE; i++)
{
for (uint32_t j = 0; j < MAX_SPHERE; j++)
{
// These are used in the fragment shader
bgfx::setTexture(0, s_normal, m_gbuffer, GBUFFER_RT_NORMAL); // Normal for lighting calculations
bgfx::setTexture(1, s_depth, m_gbuffer, GBUFFER_RT_DEPTH); // Depth to reconstruct world position
// Thse are used in the vert shader
bgfx::setTexture(2, s_shadowMap, m_shadowBuffer, SHADOW_RT_DEPTH); // Used to place sphere
bgfx::setTexture(3, s_rsm, m_shadowBuffer, SHADOW_RT_RSM); // Used to scale/color sphere
bgfx::setUniform(u_invMvp, invMvp);
bgfx::setUniform(u_invMvpShadow, invMvpShadow);
float sphereInfo[4];
sphereInfo[0] = ((float)i/(MAX_SPHERE-1));
sphereInfo[1] = ((float)j/(MAX_SPHERE-1));
sphereInfo[2] = m_vplRadius;
sphereInfo[3] = 0.0; // Unused
bgfx::setUniform(u_sphereInfo, sphereInfo);
const uint64_t lightDrawState = 0
| BGFX_STATE_RGB_WRITE
| BGFX_STATE_BLEND_ADD // <=== Overlapping lights contribute more
| BGFX_STATE_ALPHA_WRITE
| BGFX_STATE_CULL_CW // <=== If we go into the lights, there will be problems, so we draw the far back face.
;
meshSubmit(
m_lightSphere,
RENDER_PASS_LIGHT_BUFFER,
m_lightProgram,
NULL,
lightDrawState
);
}
}
// Draw combine pass
// Texture inputs for combine pass
bgfx::setTexture(0, s_normal, m_gbuffer, GBUFFER_RT_NORMAL);
bgfx::setTexture(1, s_color, m_gbuffer, GBUFFER_RT_COLOR);
bgfx::setTexture(2, s_light, m_lightBuffer, 0);
bgfx::setTexture(3, s_depth, m_gbuffer, GBUFFER_RT_DEPTH);
bgfx::setTexture(4, s_shadowMap, m_shadowBuffer, SHADOW_RT_DEPTH, BGFX_TEXTURE_COMPARE_LEQUAL);
// Uniforms for combine pass
bgfx::setUniform(u_lightDir, m_lightDir);
bgfx::setUniform(u_invMvp, invMvp);
bgfx::setUniform(u_lightMtx, lightMtx);
const float invDim[4] = {1.0f/SHADOW_MAP_DIM, 0.0f, 0.0f, 0.0f};
bgfx::setUniform(u_shadowDimsInv, invDim);
float rsmAmount[4] = {m_rsmAmount,m_rsmAmount,m_rsmAmount,m_rsmAmount};
bgfx::setUniform(u_rsmAmount, rsmAmount);
// Set up state for combine pass
// point of this is to avoid doing depth test, which is in the default state
bgfx::setState(0
| BGFX_STATE_RGB_WRITE
| BGFX_STATE_ALPHA_WRITE
);
// Set up transform matrix for fullscreen quad
float orthoProj[16];
bx::mtxOrtho(orthoProj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
bgfx::setViewTransform(RENDER_PASS_COMBINE, NULL, orthoProj);
bgfx::setViewRect(RENDER_PASS_COMBINE, 0, 0, m_width, m_height);
// Bind vertex buffer and draw quad
screenSpaceQuad( (float)m_width, (float)m_height, m_texelHalf, m_caps->originBottomLeft);
bgfx::submit(RENDER_PASS_COMBINE, m_combineProgram);
// Draw UI
imguiBeginFrame(m_mouseState.m_mx
, m_mouseState.m_my
, (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
| (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
| (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
, m_mouseState.m_mz
, m_width
, m_height
);
imguiBeginArea("RSM:", 10, 100, 300, 400);
imguiSlider("rsm amount", m_rsmAmount, 0.0f, 0.7f, 0.01f);
imguiSlider("vpl radius", m_vplRadius, 0.25f, 20.0f, 0.1f);
imguiSlider("light azimuth", m_lightAzimuth, 0.0f, 360.0f, 0.01f);
imguiSlider("light elevation", m_lightElevation, 35.0f, 90.0f, 0.01f);
imguiEndArea();
imguiEndFrame();
updateLightDir();
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
m_currFrame = bgfx::frame();
return true;
}
return false;
}
void drawAllModels(uint8_t _pass, bgfx::ProgramHandle _program)
{
for (uint32_t ii = 0; ii < BX_COUNTOF(m_models); ++ii)
{
const Model& model = m_models[ii];
// Set up transform matrix for each model
float scale = s_meshScale[model.mesh];
float mtx[16];
bx::mtxSRT(mtx
, scale
, scale
, scale
, 0.0f
, 0.0f
, 0.0f
, model.position[0]
, model.position[1]
, model.position[2]
);
// Submit mesh to gbuffer
bgfx::setUniform(u_tint, model.color);
meshSubmit(m_meshes[model.mesh], _pass, _program, mtx);
}
// Draw ground
const float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
bgfx::setUniform(u_tint, white);
float mtxScale[16];
float scale = 10.0;
bx::mtxScale(mtxScale
, scale
, scale
, scale
);
float mtxTrans[16];
bx::mtxTranslate(mtxTrans
, 0.0f
, -10.0f
, 0.0f
);
float mtx[16];
bx::mtxMul(mtx, mtxScale, mtxTrans);
meshSubmit(m_ground, _pass, _program, mtx);
}
void updateLightDir()
{
float el = m_lightElevation * (bx::pi/180.0f);
float az = m_lightAzimuth * (bx::pi/180.0f);
m_lightDir[0] = cos(el)*cos(az);
m_lightDir[2] = cos(el)*sin(az);
m_lightDir[1] = sin(el);
m_lightDir[3] = 0.0f;
}
uint32_t m_width;
uint32_t m_height;
uint32_t m_debug;
uint32_t m_reset;
entry::MouseState m_mouseState;
Mesh* m_ground;
Mesh* m_lightSphere; // Unit sphere
// Resource handles
bgfx::ProgramHandle m_gbufferProgram;
bgfx::ProgramHandle m_shadowProgram;
bgfx::ProgramHandle m_lightProgram;
bgfx::ProgramHandle m_combineProgram;
bgfx::FrameBufferHandle m_gbuffer;
bgfx::FrameBufferHandle m_lightBuffer;
bgfx::FrameBufferHandle m_shadowBuffer;
// Shader uniforms
bgfx::UniformHandle u_tint;
bgfx::UniformHandle u_invMvp;
bgfx::UniformHandle u_invMvpShadow;
bgfx::UniformHandle u_lightMtx;
bgfx::UniformHandle u_lightDir;
bgfx::UniformHandle u_sphereInfo;
bgfx::UniformHandle u_shadowDimsInv;
bgfx::UniformHandle u_rsmAmount;
// Uniforms to identify texture samples
bgfx::UniformHandle s_normal;
bgfx::UniformHandle s_depth;
bgfx::UniformHandle s_color;
bgfx::UniformHandle s_light;
bgfx::UniformHandle s_shadowMap;
bgfx::UniformHandle s_rsm;
// Various render targets
bgfx::TextureHandle m_gbufferTex[3];
bgfx::TextureHandle m_lightBufferTex;
bgfx::TextureHandle m_shadowBufferTex[2];
const bgfx::Caps* m_caps;
struct Model
{
uint32_t mesh; // Index of mesh in m_meshes
float color[4];
float position[3];
};
Model m_models[MODEL_COUNT];
Mesh * m_meshes[BX_COUNTOF(s_meshPaths)];
uint32_t m_reading;
uint32_t m_currFrame;
// UI
bool m_cameraSpin;
// Light position;
float m_lightDir[4];
float m_lightElevation;
float m_lightAzimuth;
float m_rsmAmount; // Amount of rsm
float m_vplRadius; // Radius of virtual point light
float m_texelHalf;
};
ENTRY_IMPLEMENT_MAIN(ExampleRSM);

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

View File

@ -0,0 +1,10 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec3 v_view : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
vec4 v_lightCenterScale : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); // xyz is position z is scale
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;
vec2 a_texcoord0 : TEXCOORD0;
vec3 a_normal : NORMAL;

View File

@ -0,0 +1,15 @@
$input a_position, a_texcoord0
$output v_texcoord0
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
v_texcoord0 = a_texcoord0;
}

View File

@ -0,0 +1,27 @@
$input a_position, a_normal
$output v_normal
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
uniform vec4 u_tint;
void main()
{
// Calculate vertex position
vec3 pos = a_position;
gl_Position = mul(u_modelViewProj, vec4(pos, 1.0) );
// Calculate normal. Note that compressed normal is stored in the vertices
vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1].
// Transform normal into world space.
vec3 normalWorldSpace = mul(u_model[0], vec4(normalObjectSpace, 0.0) ).xyz;
// Normalize to remove (uniform...) scaling, however, recompress
v_normal.xyz = normalize(normalWorldSpace)*0.5+0.5;
}

View File

@ -0,0 +1,60 @@
$input a_position
$output v_lightCenterScale, v_color0
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
uniform vec4 u_sphereInfo;
uniform mat4 u_invMvpShadow;
// Note texture binding starts at slot 2. Problem is that vert textures and frag textures are different.
SAMPLER2D(s_shadowMap, 2); // Used to reconstruct 3d position for lights
SAMPLER2D(s_rsm, 3); // Reflective shadow map, used to scale/color light
float toClipSpaceDepth(float _depthTextureZ)
{
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
{
vec4 wpos = mul(_invViewProj, vec4(_clipPos, 1.0) );
return wpos.xyz / wpos.w;
}
void main()
{
// Calculate vertex position
vec3 objectSpacePos = a_position;
vec2 texCoord = u_sphereInfo.xy;
// Get world position using the shadow map
float deviceDepth = texture2DLod(s_shadowMap, texCoord, 0).x;
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(texCoord * 2.0 - 1.0, depth);
#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wPos = clipToWorld(u_invMvpShadow, clip);
wPos.y -= 0.001; // Would be much better to perturb in normal direction, but I didn't do that.
// Scale and color are already in the rsm
vec4 rsm = texture2DLod(s_rsm, texCoord, 0).xyzw;
float radScale = u_sphereInfo.z;
float rad = rsm.w * radScale;
gl_Position = mul(u_viewProj, vec4(wPos+objectSpacePos*rad, 1.0) );
v_lightCenterScale.xyz = wPos.xyz;
v_lightCenterScale.w = rad;
v_color0.xyz = rsm.xyz;
}

View File

@ -0,0 +1,24 @@
$input a_position, a_normal
$output v_normal // RSM shadow
/*
* Copyright 2016 Joseph Cherlin. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
uniform vec4 u_tint;
void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
// Calculate normal. Note that compressed normal is stored in the vertices
vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1].
// Transform normal into view space.
v_normal = mul(u_modelView, vec4(normalObjectSpace, 0.0) ).xyz;
// Normalize to remove (uniform...) scaling
v_normal = normalize(v_normal);
}

View File

@ -1,18 +0,0 @@
include ../../../scripts/common.ninja
meshes = ../../runtime/meshes
build $meshes/bunny.bin: geometryc_pack_normal bunny.obj
build $meshes/bunny_decimated.bin: geometryc_pack_normal bunny_decimated.obj
build $meshes/bunny_patched.bin: geometryc_pack_normal bunny_patched.obj
build $meshes/column.bin: geometryc_pack_normal column.obj
build $meshes/cube.bin: geometryc_pack_normal cube.obj
build $meshes/hollowcube.bin: geometryc_pack_normal hollowcube.obj
build $meshes/orb.bin: geometryc_pack_normal orb.obj
build $meshes/platform.bin: geometryc_pack_normal platform.obj
build $meshes/tree.bin: geometryc_pack_normal tree.obj
build $meshes/tree1b_lod0_1.bin: geometryc_pack_normal tree1b_lod0_1.obj
build $meshes/tree1b_lod0_2.bin: geometryc_pack_normal tree1b_lod0_2.obj
build $meshes/tree1b_lod1_1.bin: geometryc_pack_normal tree1b_lod1_1.obj
build $meshes/tree1b_lod1_2.bin: geometryc_pack_normal tree1b_lod1_2.obj
build $meshes/tree1b_lod2_1.bin: geometryc_pack_normal tree1b_lod2_1.obj
build $meshes/tree1b_lod2_2.bin: geometryc_pack_normal tree1b_lod2_2.obj

View File

@ -0,0 +1,17 @@
meshes = $pwd/../../runtime/meshes
build $meshes/bunny.bin: geometryc_pack_normal_barycentric $pwd/bunny.obj
build $meshes/bunny_decimated.bin: geometryc_pack_normal $pwd/bunny_decimated.obj
build $meshes/bunny_patched.bin: geometryc_pack_normal $pwd/bunny_patched.obj
build $meshes/column.bin: geometryc_pack_normal $pwd/column.obj
build $meshes/cube.bin: geometryc_pack_normal $pwd/cube.obj
build $meshes/hollowcube.bin: geometryc_pack_normal_barycentric $pwd/hollowcube.obj
build $meshes/orb.bin: geometryc_pack_normal_barycentric $pwd/orb.obj
build $meshes/platform.bin: geometryc_pack_normal $pwd/platform.obj
build $meshes/tree.bin: geometryc_pack_normal $pwd/tree.obj
build $meshes/tree1b_lod0_1.bin: geometryc_pack_normal $pwd/tree1b_lod0_1.obj
build $meshes/tree1b_lod0_2.bin: geometryc_pack_normal $pwd/tree1b_lod0_2.obj
build $meshes/tree1b_lod1_1.bin: geometryc_pack_normal $pwd/tree1b_lod1_1.obj
build $meshes/tree1b_lod1_2.bin: geometryc_pack_normal $pwd/tree1b_lod1_2.obj
build $meshes/tree1b_lod2_1.bin: geometryc_pack_normal $pwd/tree1b_lod2_1.obj
build $meshes/tree1b_lod2_2.bin: geometryc_pack_normal $pwd/tree1b_lod2_2.obj

View File

@ -1,8 +0,0 @@
include ../../../scripts/common.ninja
textures = ../../runtime/textures
build $textures/texture_compression_bc1.ktx: texturec_bc1 texture_compression.png
build $textures/texture_compression_bc2.ktx: texturec_bc2 texture_compression.png
build $textures/texture_compression_bc3.ktx: texturec_bc3 texture_compression.png
build $textures/texture_compression_etc1.ktx: texturec_etc1 texture_compression.png
build $textures/texture_compression_etc2.ktx: texturec_etc2 texture_compression.png

View File

@ -0,0 +1,7 @@
textures = $pwd/../../runtime/textures
build $textures/texture_compression_bc1.ktx: texturec_bc1 $pwd/texture_compression.png
build $textures/texture_compression_bc2.ktx: texturec_bc2 $pwd/texture_compression.png
build $textures/texture_compression_bc3.ktx: texturec_bc3 $pwd/texture_compression.png
build $textures/texture_compression_etc1.ktx: texturec_etc1 $pwd/texture_compression.png
build $textures/texture_compression_etc2.ktx: texturec_etc2 $pwd/texture_compression.png

View File

@ -149,6 +149,7 @@ bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t&
{
m_skyline.erase(m_skyline.begin() + ii);
--ii;
--num;
}
else
{

View File

@ -39,13 +39,14 @@ struct DebugShapeVertex
float m_x;
float m_y;
float m_z;
float m_mask;
uint8_t m_indices[4];
static void init()
{
ms_decl
.begin()
.add(bgfx::Attrib::Position, 4, bgfx::AttribType::Float)
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
.add(bgfx::Attrib::Indices, 4, bgfx::AttribType::Uint8)
.end();
}
@ -56,14 +57,14 @@ bgfx::VertexDecl DebugShapeVertex::ms_decl;
static DebugShapeVertex s_cubeVertices[8] =
{
{-1.0f, 1.0f, 1.0f, 0.0f },
{ 1.0f, 1.0f, 1.0f, 0.0f },
{-1.0f, -1.0f, 1.0f, 0.0f },
{ 1.0f, -1.0f, 1.0f, 0.0f },
{-1.0f, 1.0f, -1.0f, 0.0f },
{ 1.0f, 1.0f, -1.0f, 0.0f },
{-1.0f, -1.0f, -1.0f, 0.0f },
{ 1.0f, -1.0f, -1.0f, 0.0f },
{-1.0f, 1.0f, 1.0f, { 0, 0, 0, 0 } },
{ 1.0f, 1.0f, 1.0f, { 0, 0, 0, 0 } },
{-1.0f, -1.0f, 1.0f, { 0, 0, 0, 0 } },
{ 1.0f, -1.0f, 1.0f, { 0, 0, 0, 0 } },
{-1.0f, 1.0f, -1.0f, { 0, 0, 0, 0 } },
{ 1.0f, 1.0f, -1.0f, { 0, 0, 0, 0 } },
{-1.0f, -1.0f, -1.0f, { 0, 0, 0, 0 } },
{ 1.0f, -1.0f, -1.0f, { 0, 0, 0, 0 } },
};
static const uint16_t s_cubeIndices[36] =
@ -389,6 +390,7 @@ struct DebugDraw
const uint32_t numIndices = numVertices;
vertices[id] = BX_ALLOC(m_allocator, numVertices*stride);
memset(vertices[id], 0, numVertices*stride);
genSphere(tess, vertices[id], stride);
uint16_t* trilist = (uint16_t*)BX_ALLOC(m_allocator, numIndices*sizeof(uint16_t) );
@ -397,9 +399,6 @@ struct DebugDraw
trilist[ii] = uint16_t(ii);
}
uint32_t numLineListIndices = bgfx::topologyConvert(bgfx::TopologyConvert::TriListToLineList
, NULL
, 0
@ -432,6 +431,207 @@ struct DebugDraw
BX_FREE(m_allocator, trilist);
}
for (uint32_t mesh = 0; mesh < 4; ++mesh)
{
Mesh::Enum id = Mesh::Enum(Mesh::Cone0+mesh);
const uint32_t num = getCircleLod(uint8_t(mesh) );
const float step = bx::pi * 2.0f / num;
const uint32_t numVertices = num+1;
const uint32_t numIndices = num*6;
const uint32_t numLineListIndices = num*4;
vertices[id] = BX_ALLOC(m_allocator, numVertices*stride);
indices[id] = (uint16_t*)BX_ALLOC(m_allocator, (numIndices + numLineListIndices)*sizeof(uint16_t) );
memset(indices[id], 0, (numIndices + numLineListIndices)*sizeof(uint16_t) );
DebugShapeVertex* vertex = (DebugShapeVertex*)vertices[id];
uint16_t* index = indices[id];
vertex[num].m_x = 0.0f;
vertex[num].m_y = 0.0f;
vertex[num].m_z = 0.0f;
vertex[num].m_indices[0] = 1;
for (uint32_t ii = 0; ii < num; ++ii)
{
const float angle = step * ii;
float xy[2];
circle(xy, angle);
vertex[ii].m_x = xy[1];
vertex[ii].m_y = 0.0f;
vertex[ii].m_z = xy[0];
vertex[ii].m_indices[0] = 0;
index[ii*3+0] = uint16_t(num);
index[ii*3+1] = uint16_t( (ii+1)%num);
index[ii*3+2] = uint16_t(ii);
index[num*3+ii*3+0] = 0;
index[num*3+ii*3+1] = uint16_t(ii);
index[num*3+ii*3+2] = uint16_t( (ii+1)%num);
index[numIndices+ii*2+0] = uint16_t(ii);
index[numIndices+ii*2+1] = uint16_t(num);
index[numIndices+num*2+ii*2+0] = uint16_t(ii);
index[numIndices+num*2+ii*2+1] = uint16_t( (ii+1)%num);
}
m_mesh[id].m_startVertex = startVertex;
m_mesh[id].m_numVertices = numVertices;
m_mesh[id].m_startIndex[0] = startIndex;
m_mesh[id].m_numIndices[0] = numIndices;
m_mesh[id].m_startIndex[1] = startIndex+numIndices;
m_mesh[id].m_numIndices[1] = numLineListIndices;
startVertex += numVertices;
startIndex += numIndices + numLineListIndices;
}
for (uint32_t mesh = 0; mesh < 4; ++mesh)
{
Mesh::Enum id = Mesh::Enum(Mesh::Cylinder0+mesh);
const uint32_t num = getCircleLod(uint8_t(mesh) );
const float step = bx::pi * 2.0f / num;
const uint32_t numVertices = num*2;
const uint32_t numIndices = num*12;
const uint32_t numLineListIndices = num*6;
vertices[id] = BX_ALLOC(m_allocator, numVertices*stride);
indices[id] = (uint16_t*)BX_ALLOC(m_allocator, (numIndices + numLineListIndices)*sizeof(uint16_t) );
memset(indices[id], 0, (numIndices + numLineListIndices)*sizeof(uint16_t) );
DebugShapeVertex* vertex = (DebugShapeVertex*)vertices[id];
uint16_t* index = indices[id];
for (uint32_t ii = 0; ii < num; ++ii)
{
const float angle = step * ii;
float xy[2];
circle(xy, angle);
vertex[ii].m_x = xy[1];
vertex[ii].m_y = 0.0f;
vertex[ii].m_z = xy[0];
vertex[ii].m_indices[0] = 0;
vertex[ii+num].m_x = xy[1];
vertex[ii+num].m_y = 0.0f;
vertex[ii+num].m_z = xy[0];
vertex[ii+num].m_indices[0] = 1;
index[ii*6+0] = uint16_t(ii+num);
index[ii*6+1] = uint16_t( (ii+1)%num);
index[ii*6+2] = uint16_t(ii);
index[ii*6+3] = uint16_t(ii+num);
index[ii*6+4] = uint16_t( (ii+1)%num+num);
index[ii*6+5] = uint16_t( (ii+1)%num);
index[num*6+ii*6+0] = uint16_t(0);
index[num*6+ii*6+1] = uint16_t(ii);
index[num*6+ii*6+2] = uint16_t( (ii+1)%num);
index[num*6+ii*6+3] = uint16_t(num);
index[num*6+ii*6+4] = uint16_t( (ii+1)%num+num);
index[num*6+ii*6+5] = uint16_t(ii+num);
index[numIndices+ii*2+0] = uint16_t(ii);
index[numIndices+ii*2+1] = uint16_t(ii+num);
index[numIndices+num*2+ii*2+0] = uint16_t(ii);
index[numIndices+num*2+ii*2+1] = uint16_t( (ii+1)%num);
index[numIndices+num*4+ii*2+0] = uint16_t(num + ii);
index[numIndices+num*4+ii*2+1] = uint16_t(num + (ii+1)%num);
}
m_mesh[id].m_startVertex = startVertex;
m_mesh[id].m_numVertices = numVertices;
m_mesh[id].m_startIndex[0] = startIndex;
m_mesh[id].m_numIndices[0] = numIndices;
m_mesh[id].m_startIndex[1] = startIndex+numIndices;
m_mesh[id].m_numIndices[1] = numLineListIndices;
startVertex += numVertices;
startIndex += numIndices + numLineListIndices;
}
for (uint32_t mesh = 0; mesh < 4; ++mesh)
{
Mesh::Enum id = Mesh::Enum(Mesh::Capsule0+mesh);
const uint32_t num = getCircleLod(uint8_t(mesh) );
const float step = bx::pi * 2.0f / num;
const uint32_t numVertices = num*2;
const uint32_t numIndices = num*6;
const uint32_t numLineListIndices = num*6;
vertices[id] = BX_ALLOC(m_allocator, numVertices*stride);
indices[id] = (uint16_t*)BX_ALLOC(m_allocator, (numIndices + numLineListIndices)*sizeof(uint16_t) );
memset(indices[id], 0, (numIndices + numLineListIndices)*sizeof(uint16_t) );
DebugShapeVertex* vertex = (DebugShapeVertex*)vertices[id];
uint16_t* index = indices[id];
for (uint32_t ii = 0; ii < num; ++ii)
{
const float angle = step * ii;
float xy[2];
circle(xy, angle);
vertex[ii].m_x = xy[1];
vertex[ii].m_y = 0.0f;
vertex[ii].m_z = xy[0];
vertex[ii].m_indices[0] = 0;
vertex[ii+num].m_x = xy[1];
vertex[ii+num].m_y = 0.0f;
vertex[ii+num].m_z = xy[0];
vertex[ii+num].m_indices[0] = 1;
index[ii*6+0] = uint16_t(ii+num);
index[ii*6+1] = uint16_t( (ii+1)%num);
index[ii*6+2] = uint16_t(ii);
index[ii*6+3] = uint16_t(ii+num);
index[ii*6+4] = uint16_t( (ii+1)%num+num);
index[ii*6+5] = uint16_t( (ii+1)%num);
// index[num*6+ii*6+0] = uint16_t(0);
// index[num*6+ii*6+1] = uint16_t(ii);
// index[num*6+ii*6+2] = uint16_t( (ii+1)%num);
// index[num*6+ii*6+3] = uint16_t(num);
// index[num*6+ii*6+4] = uint16_t( (ii+1)%num+num);
// index[num*6+ii*6+5] = uint16_t(ii+num);
index[numIndices+ii*2+0] = uint16_t(ii);
index[numIndices+ii*2+1] = uint16_t(ii+num);
index[numIndices+num*2+ii*2+0] = uint16_t(ii);
index[numIndices+num*2+ii*2+1] = uint16_t( (ii+1)%num);
index[numIndices+num*4+ii*2+0] = uint16_t(num + ii);
index[numIndices+num*4+ii*2+1] = uint16_t(num + (ii+1)%num);
}
m_mesh[id].m_startVertex = startVertex;
m_mesh[id].m_numVertices = numVertices;
m_mesh[id].m_startIndex[0] = startIndex;
m_mesh[id].m_numIndices[0] = numIndices;
m_mesh[id].m_startIndex[1] = startIndex+numIndices;
m_mesh[id].m_numIndices[1] = numLineListIndices;
startVertex += numVertices;
startIndex += numIndices + numLineListIndices;
}
m_mesh[Mesh::Cube].m_startVertex = startVertex;
m_mesh[Mesh::Cube].m_numVertices = BX_COUNTOF(s_cubeVertices);
m_mesh[Mesh::Cube].m_startIndex[0] = startIndex;
@ -444,9 +644,9 @@ struct DebugDraw
const bgfx::Memory* vb = bgfx::alloc(startVertex*stride);
const bgfx::Memory* ib = bgfx::alloc(startIndex*sizeof(uint16_t) );
for (uint32_t mesh = 0; mesh < 4; ++mesh)
for (uint32_t mesh = Mesh::Sphere0; mesh < Mesh::Cube; ++mesh)
{
Mesh::Enum id = Mesh::Enum(Mesh::Sphere0+mesh);
Mesh::Enum id = Mesh::Enum(mesh);
memcpy(&vb->data[m_mesh[id].m_startVertex * stride]
, vertices[id]
, m_mesh[id].m_numVertices*stride
@ -780,7 +980,7 @@ struct DebugDraw
void draw(const Cylinder& _cylinder, bool _capsule)
{
BX_UNUSED(_cylinder, _capsule);
drawCylinder(_cylinder.m_pos, _cylinder.m_end, _cylinder.m_radius, _capsule);
}
void draw(const Disk& _disk)
@ -823,7 +1023,7 @@ struct DebugDraw
}
else
{
draw(Mesh::Cube, _obb.m_mtx, false);
draw(Mesh::Cube, _obb.m_mtx, 1, false);
}
}
@ -846,7 +1046,7 @@ struct DebugDraw
? uint8_t(Mesh::SphereMaxLod)
: attrib.m_lod
;
draw(Mesh::Enum(Mesh::Sphere0 + lod), mtx, attrib.m_wireframe);
draw(Mesh::Enum(Mesh::Sphere0 + lod), mtx, 1, attrib.m_wireframe);
}
void drawFrustum(const float* _viewProj)
@ -936,7 +1136,7 @@ struct DebugDraw
lineTo(_x, _y, _z);
}
void drawCircle(const float* _normal, const float* _center, float _radius, float _weight = 0.0f)
void drawCircle(const float* _normal, const float* _center, float _radius, float _weight)
{
const Attrib& attrib = m_attrib[m_stack];
const uint32_t num = getCircleLod(attrib.m_lod);
@ -979,12 +1179,12 @@ struct DebugDraw
close();
}
void drawCircle(const void* _normal, const void* _center, float _radius, float _weight = 0.0f)
void drawCircle(const void* _normal, const void* _center, float _radius, float _weight)
{
drawCircle( (const float*)_normal, (const float*)_center, _radius, _weight);
}
void drawCircle(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _weight = 0.0f)
void drawCircle(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _weight)
{
const Attrib& attrib = m_attrib[m_stack];
const uint32_t num = getCircleLod(attrib.m_lod);
@ -1018,136 +1218,127 @@ struct DebugDraw
close();
}
void drawCone(const float* _from, const float* _to, float _radius, float _weight = 0.0f)
void drawCone(const float* _from, const float* _to, float _radius)
{
const Attrib& attrib = m_attrib[m_stack];
const uint32_t num = getCircleLod(attrib.m_lod);
const float step = bx::pi * 2.0f / num;
_weight = bx::fclamp(_weight, 0.0f, 2.0f);
float pos[3];
float tmp0[3];
float tmp1[3];
bx::vec3Sub(tmp0, _from, _to);
Plane plane;
plane.m_dist = 0.0f;
bx::vec3Norm(plane.m_normal, tmp0);
float normal[3];
bx::vec3Norm(normal, tmp0);
float udir[3];
float vdir[3];
calcPlaneUv(plane, udir, vdir);
float mtx[2][16];
bx::mtxFromNormal(mtx[0], normal, _radius, _from);
float xy0[2];
float xy1[2];
circle(xy0, 0.0f);
squircle(xy1, 0.0f);
memcpy(mtx[1], mtx[0], 64);
mtx[1][12] = _to[0];
mtx[1][13] = _to[1];
mtx[1][14] = _to[2];
bx::vec3Mul(pos, udir, bx::flerp(xy0[0], xy1[0], _weight)*_radius);
bx::vec3Mul(tmp0, vdir, bx::flerp(xy0[1], xy1[1], _weight)*_radius);
bx::vec3Add(tmp1, pos, tmp0);
bx::vec3Add(pos, tmp1, _from);
moveTo(pos);
uint8_t lod = attrib.m_lod > Mesh::ConeMaxLod
? uint8_t(Mesh::ConeMaxLod)
: attrib.m_lod
;
draw(Mesh::Enum(Mesh::Cone0 + lod), mtx[0], 2, attrib.m_wireframe);
}
for (uint32_t ii = 1; ii < num; ++ii)
void drawCone(const void* _from, const void* _to, float _radius)
{
float angle = step * ii;
circle(xy0, angle);
squircle(xy1, angle);
bx::vec3Mul(pos, udir, bx::flerp(xy0[0], xy1[0], _weight)*_radius);
bx::vec3Mul(tmp0, vdir, bx::flerp(xy0[1], xy1[1], _weight)*_radius);
bx::vec3Add(tmp1, pos, tmp0);
bx::vec3Add(pos, tmp1, _from);
lineTo(pos);
drawCone( (const float*)_from, (const float*)_to, _radius);
}
close();
for (uint32_t ii = 0; ii < num; ++ii)
{
float angle = step * ii;
circle(xy0, angle);
squircle(xy1, angle);
bx::vec3Mul(pos, udir, bx::flerp(xy0[0], xy1[0], _weight)*_radius);
bx::vec3Mul(tmp0, vdir, bx::flerp(xy0[1], xy1[1], _weight)*_radius);
bx::vec3Add(tmp1, pos, tmp0);
bx::vec3Add(pos, tmp1, _from);
moveTo(pos);
lineTo(_to);
}
}
void drawCone(const void* _from, const void* _to, float _radius, float _weight = 0.0f)
{
drawCone( (const float*)_from, (const float*)_to, _radius, _weight);
}
void drawCylinder(const float* _from, const float* _to, float _radius, float _weight = 0.0f)
void drawCylinder(const float* _from, const float* _to, float _radius, bool _capsule)
{
const Attrib& attrib = m_attrib[m_stack];
const uint32_t num = getCircleLod(attrib.m_lod);
const float step = bx::pi * 2.0f / num;
_weight = bx::fclamp(_weight, 0.0f, 2.0f);
float pos[3];
float tmp0[3];
float tmp1[3];
bx::vec3Sub(tmp0, _from, _to);
Plane plane;
plane.m_dist = 0.0f;
bx::vec3Norm(plane.m_normal, tmp0);
float normal[3];
bx::vec3Norm(normal, tmp0);
float udir[3];
float vdir[3];
calcPlaneUv(plane, udir, vdir);
float mtx[2][16];
bx::mtxFromNormal(mtx[0], normal, _radius, _from);
float xy0[2];
float xy1[2];
circle(xy0, 0.0f);
squircle(xy1, 0.0f);
memcpy(mtx[1], mtx[0], 64);
mtx[1][12] = _to[0];
mtx[1][13] = _to[1];
mtx[1][14] = _to[2];
float pos1[3];
bx::vec3Mul(pos, udir, bx::flerp(xy0[0], xy1[0], _weight)*_radius);
bx::vec3Mul(tmp0, vdir, bx::flerp(xy0[1], xy1[1], _weight)*_radius);
bx::vec3Add(tmp1, pos, tmp0);
bx::vec3Add(pos, tmp1, _from);
bx::vec3Add(pos1, tmp1, _to);
for (uint32_t ii = 1; ii < num+1; ++ii)
if (_capsule)
{
float angle = step * ii;
circle(xy0, angle);
squircle(xy1, angle);
uint8_t lod = attrib.m_lod > Mesh::CapsuleMaxLod
? uint8_t(Mesh::CapsuleMaxLod)
: attrib.m_lod
;
draw(Mesh::Enum(Mesh::Capsule0 + lod), mtx[0], 2, attrib.m_wireframe);
moveTo(pos); lineTo(pos1);
Sphere sphere;
bx::vec3Move(sphere.m_center, _from);
sphere.m_radius = _radius;
draw(sphere);
moveTo(pos);
bx::vec3Mul(pos, udir, bx::flerp(xy0[0], xy1[0], _weight)*_radius);
bx::vec3Mul(tmp0, vdir, bx::flerp(xy0[1], xy1[1], _weight)*_radius);
bx::vec3Add(tmp1, pos, tmp0);
bx::vec3Add(pos, tmp1, _from);
lineTo(pos);
moveTo(pos1);
bx::vec3Add(pos1, tmp1, _to);
lineTo(pos1);
bx::vec3Move(sphere.m_center, _to);
draw(sphere);
}
}
void drawCylinder(const void* _from, const void* _to, float _radius, float _weight = 0.0f)
else
{
drawCylinder( (const float*)_from, (const float*)_to, _radius, _weight);
uint8_t lod = attrib.m_lod > Mesh::CylinderMaxLod
? uint8_t(Mesh::CylinderMaxLod)
: attrib.m_lod
;
draw(Mesh::Enum(Mesh::Cylinder0 + lod), mtx[0], 2, attrib.m_wireframe);
}
}
void drawAxis(float _x, float _y, float _z, float _len, Axis::Enum _highlight)
void drawCylinder(const void* _from, const void* _to, float _radius, bool _capsule)
{
drawCylinder( (const float*)_from, (const float*)_to, _radius, _capsule);
}
void drawAxis(float _x, float _y, float _z, float _len, Axis::Enum _highlight, float _thickness)
{
push();
if (_thickness > 0.0f)
{
float from[3] = { _x, _y, _z };
float mid[3];
float to[3];
setColor(Axis::X == _highlight ? 0xff00ffff : 0xff0000ff);
mid[0] = _x + _len - _thickness;
mid[1] = _y;
mid[2] = _z;
to[0] = _x + _len;
to[1] = _y;
to[2] = _z;
drawCylinder(from, mid, _thickness, false);
drawCone(mid, to, _thickness);
setColor(Axis::Y == _highlight ? 0xff00ffff : 0xff00ff00);
mid[0] = _x;
mid[1] = _y + _len - _thickness;
mid[2] = _z;
to[0] = _x;
to[1] = _y + _len;
to[2] = _z;
drawCylinder(from, mid, _thickness, false);
drawCone(mid, to, _thickness);
setColor(Axis::Z == _highlight ? 0xff00ffff : 0xffff0000);
mid[0] = _x;
mid[1] = _y;
mid[2] = _z + _len - _thickness;
to[0] = _x;
to[1] = _y;
to[2] = _z + _len;
drawCylinder(from, mid, _thickness, false);
drawCone(mid, to, _thickness);
}
else
{
setColor(Axis::X == _highlight ? 0xff00ffff : 0xff0000ff);
moveTo(_x, _y, _z);
lineTo(_x + _len, _y, _z);
@ -1159,6 +1350,7 @@ struct DebugDraw
setColor(Axis::Z == _highlight ? 0xff00ffff : 0xffff0000);
moveTo(_x, _y, _z);
lineTo(_x, _y, _z + _len);
}
pop();
}
@ -1274,13 +1466,13 @@ struct DebugDraw
push();
setColor(Axis::X == _hightlight ? 0xff00ffff : 0xff0000ff);
drawCircle(Axis::X, _x, _y, _z, _radius);
drawCircle(Axis::X, _x, _y, _z, _radius, 0.0f);
setColor(Axis::Y == _hightlight ? 0xff00ffff : 0xff00ff00);
drawCircle(Axis::Y, _x, _y, _z, _radius);
drawCircle(Axis::Y, _x, _y, _z, _radius, 0.0f);
setColor(Axis::Z == _hightlight ? 0xff00ffff : 0xffff0000);
drawCircle(Axis::Z, _x, _y, _z, _radius);
drawCircle(Axis::Z, _x, _y, _z, _radius, 0.0f);
pop();
}
@ -1294,11 +1486,30 @@ private:
Sphere1,
Sphere2,
Sphere3,
Cone0,
Cone1,
Cone2,
Cone3,
Cylinder0,
Cylinder1,
Cylinder2,
Cylinder3,
Capsule0,
Capsule1,
Capsule2,
Capsule3,
Cube,
Count,
SphereMaxLod = Sphere3 - Sphere0,
ConeMaxLod = Cone3 - Cone0,
CylinderMaxLod = Cylinder3 - Cylinder0,
CapsuleMaxLod = Capsule3 - Capsule0,
};
uint32_t m_startVertex;
@ -1320,7 +1531,7 @@ private:
};
};
void draw(Mesh::Enum _mesh, const float* _mtx, bool _wireframe) const
void draw(Mesh::Enum _mesh, const float* _mtx, uint16_t _num, bool _wireframe) const
{
const Mesh& mesh = m_mesh[_mesh];
@ -1334,31 +1545,34 @@ private:
);
}
const float flip = 0 == (attrib.m_state & BGFX_STATE_CULL_CCW) ? 1.0f : -1.0f;
const uint8_t alpha = attrib.m_abgr>>24;
float params[4][4] =
{
{
0.0f,
-1.0f,
0.0f,
3.0f,
{ // lightDir
0.0f * flip,
-1.0f * flip,
0.0f * flip,
3.0f, // shininess
},
{
{ // skyColor
1.0f,
0.9f,
0.8f,
0.0f,
0.0f, // unused
},
{
{ // groundColor.xyz0
0.2f,
0.22f,
0.5f,
0.0f,
0.0f, // unused
},
{
( (attrib.m_abgr>>24) )/255.0f,
( (attrib.m_abgr>>16)&0xff)/255.0f,
( (attrib.m_abgr>> 8)&0xff)/255.0f,
{ // matColor
( (attrib.m_abgr )&0xff)/255.0f,
( (attrib.m_abgr>> 8)&0xff)/255.0f,
( (attrib.m_abgr>>16)&0xff)/255.0f,
( alpha )/255.0f,
},
};
@ -1366,11 +1580,12 @@ private:
bgfx::setUniform(u_params, params, 4);
bgfx::setTransform(_mtx);
bgfx::setTransform(_mtx, _num);
bgfx::setVertexBuffer(m_vbh, mesh.m_startVertex, mesh.m_numVertices);
bgfx::setState(0
| attrib.m_state
| (_wireframe ? BGFX_STATE_PT_LINES|BGFX_STATE_LINEAA|BGFX_STATE_BLEND_ALPHA : 0)
| (_wireframe ? BGFX_STATE_PT_LINES|BGFX_STATE_LINEAA|BGFX_STATE_BLEND_ALPHA
: (alpha < 0xff) ? BGFX_STATE_BLEND_ALPHA : 0)
);
bgfx::submit(m_viewId, m_program[_wireframe ? Program::Fill : Program::FillLit]);
}
@ -1608,19 +1823,34 @@ void ddDrawCircle(Axis::Enum _axis, float _x, float _y, float _z, float _radius,
s_dd.drawCircle(_axis, _x, _y, _z, _radius, _weight);
}
void ddDrawCone(const void* _from, const void* _to, float _radius, float _weight)
void ddDrawCone(const void* _from, const void* _to, float _radius)
{
s_dd.drawCone(_from, _to, _radius, _weight);
s_dd.drawCone(_from, _to, _radius);
}
void ddDrawCylinder(const void* _from, const void* _to, float _radius, float _weight)
void ddDrawCylinder(const void* _from, const void* _to, float _radius, bool _capsule)
{
s_dd.drawCylinder(_from, _to, _radius, _weight);
if (_capsule)
{
s_dd.push();
s_dd.setLod(0);
s_dd.drawCylinder(_from, _to, _radius, true);
s_dd.pop();
}
else
{
s_dd.drawCylinder(_from, _to, _radius, false);
}
}
void ddDrawAxis(float _x, float _y, float _z, float _len, Axis::Enum _hightlight)
void ddDrawCapsule(const void* _from, const void* _to, float _radius)
{
s_dd.drawAxis(_x, _y, _z, _len, _hightlight);
s_dd.drawCylinder(_from, _to, _radius, true);
}
void ddDrawAxis(float _x, float _y, float _z, float _len, Axis::Enum _hightlight, float _thickness)
{
s_dd.drawAxis(_x, _y, _z, _len, _hightlight, _thickness);
}
void ddDrawGrid(const void* _normal, const void* _center, uint32_t _size, float _step)

View File

@ -103,13 +103,16 @@ void ddDrawCircle(const void* _normal, const void* _center, float _radius, float
void ddDrawCircle(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _weight = 0.0f);
///
void ddDrawCone(const void* _from, const void* _to, float _radius, float _weight = 0.0f);
void ddDrawCone(const void* _from, const void* _to, float _radius);
///
void ddDrawCylinder(const void* _from, const void* _to, float _radius, float _weight = 0.0f);
void ddDrawCylinder(const void* _from, const void* _to, float _radius, bool _capsule = false);
///
void ddDrawAxis(float _x, float _y, float _z, float _len = 1.0f, Axis::Enum _highlight = Axis::Count);
void ddDrawCapsule(const void* _from, const void* _to, float _radius);
///
void ddDrawAxis(float _x, float _y, float _z, float _len = 1.0f, Axis::Enum _highlight = Axis::Count, float _thickness = 0.0f);
///
void ddDrawGrid(const void* _normal, const void* _center, uint32_t _size = 20, float _step = 1.0f);

View File

@ -1,4 +1,5 @@
vec3 a_position : POSITION;
ivec4 a_indices : BLENDINDICES;
vec4 a_color0 : COLOR0;
float a_texcoord0 : TEXCOORD0;

View File

@ -1,107 +1,148 @@
static const uint8_t vs_debugdraw_fill_glsl[242] =
static const uint8_t vs_debugdraw_fill_glsl[329] =
{
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, // elViewProj......
0xcd, 0x00, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, // ....attribute hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, // ghp vec3 a_posit
0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, // ion;.uniform hig
0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, // hp mat4 u_modelV
0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, // iewProj;.void ma
0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, // in ().{. highp
0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, // vec4 tmpvar_1;.
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, // tmpvar_1.w = 1.
0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, // 0;. tmpvar_1.xy
0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, // z = a_position;.
0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, // gl_Position =
0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, // (u_modelViewProj
0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, // * tmpvar_1);.}.
0x0a, 0x00, // ..
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, // wProj.......u_mo
0x64, 0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x20, 0x00, 0x1b, 0x01, 0x00, 0x00, 0x61, 0x74, 0x74, // del. .. .....att
0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, // ribute highp vec
0x34, 0x20, 0x61, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x0a, 0x61, 0x74, 0x74, // 4 a_indices;.att
0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, // ribute highp vec
0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x75, 0x6e, // 3 a_position;.un
0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, // iform highp mat4
0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x75, 0x6e, 0x69, // u_viewProj;.uni
0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, // form mat4 u_mode
0x6c, 0x5b, 0x33, 0x32, 0x5d, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, // l[32];.void main
0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, // ().{. highp ve
0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, // c4 tmpvar_1;. t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, // mpvar_1.w = 1.0;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, // . tmpvar_1.xyz
0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, // = a_position;.
0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x75, // gl_Position = (u
0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x28, 0x75, 0x5f, 0x6d, // _viewProj * (u_m
0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x69, 0x6e, 0x74, 0x28, 0x61, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, // odel[int(a_indic
0x65, 0x73, 0x2e, 0x78, 0x29, 0x5d, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // es.x)] * tmpvar_
0x31, 0x29, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // 1));.}...
};
static const uint8_t vs_debugdraw_fill_dx9[287] =
static const uint8_t vs_debugdraw_fill_dx9[492] =
{
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, // elViewProj......
0xfc, 0x00, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, // ........$.CTAB..
0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, // ..W.............
0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, // ......P...0.....
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, // ......@.......u_
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x03, 0x00, // modelViewProj...
0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, // ..............vs
0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, // _3_0.Microsoft (
0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, // R) HLSL Shader C
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, // ompiler 10.0.100
0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, // 11.16384........
0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, // ................
0x0f, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x00, 0x00, // ................
0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x00, 0x00, // U...............
0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, // ................
0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ...............
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x80, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, // el. .....u_viewP
0x72, 0x6f, 0x6a, 0x04, 0x01, 0x80, 0x00, 0x04, 0x00, 0xc0, 0x01, 0x00, 0x03, 0xfe, 0xff, 0xfe, // roj.............
0xff, 0x2e, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, // ...CTAB.........
0x03, 0xfe, 0xff, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x78, // ...............x
0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x4c, // ...D...........L
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x80, 0x00, 0x04, // ................
0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // ...h.......u_mod
0x65, 0x6c, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, // el......... ....
0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0xab, 0x03, // ...u_viewProj...
0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, // ...............v
0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, // s_3_0.Microsoft
0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, // (R) HLSL Shader
0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, // Compiler 10.0.10
0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x51, 0x00, 0x00, 0x05, 0x84, // 011.16384..Q....
0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......@.........
0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, // ................
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, // ................
0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x84, // ................
0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x2e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0xb0, 0x00, // ................
0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0x55, 0x90, 0x01, // .............U..
0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0x80, 0x00, // ...............
0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, // ...............
0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x01, // ........ .......
0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, // ................
0x00, 0xe4, 0x80, 0x03, 0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x05, 0x00, 0x00, 0x03, 0x01, // .... ...........
0x00, 0x0f, 0x80, 0x00, 0x00, 0x55, 0x80, 0x81, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x01, // .....U..........
0x00, 0x0f, 0x80, 0x80, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x04, // ................
0x00, 0x00, 0x04, 0x01, 0x00, 0x0f, 0x80, 0x82, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x80, 0x01, // ................
0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0xe0, 0x83, 0x00, 0xe4, 0xa0, 0x00, // ................
0x00, 0xff, 0x80, 0x01, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, // ............
};
static const uint8_t vs_debugdraw_fill_dx11[404] =
static const uint8_t vs_debugdraw_fill_dx11[675] =
{
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, // elViewProj......
0x6c, 0x01, 0x44, 0x58, 0x42, 0x43, 0x87, 0x3c, 0x16, 0xa4, 0x8d, 0x3d, 0x5b, 0xea, 0x61, 0x5c, // l.DXBC.<...=[.a.
0x10, 0x3b, 0xa1, 0xf8, 0xf8, 0xa1, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x01, 0x00, 0x00, 0x03, 0x00, // .;........l.....
0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x49, 0x53, // ..,...`.......IS
0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, // GN,........... .
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, // ......POSITION..
0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, // ..OSGN,.........
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, // .. .............
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, // ..........SV_POS
0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x53, 0x48, 0x44, 0x52, 0xd0, 0x00, 0x00, 0x00, 0x40, 0x00, // ITION.SHDR....@.
0x01, 0x00, 0x34, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..4...Y...F. ...
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x00, 0x00, // ......_...r.....
0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, // ..g.... ........
0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, // ..h.......8.....
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, // ......V.......F.
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, // .........2.....
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......F. .......
0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, // ..........F.....
0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, // ..2...........F.
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x00, 0x00, // ...............
0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x20, // ..F............
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, // ......F.......F.
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x01, // .........>.....
0x01, 0x00, 0x40, 0x00, // ..@.
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, // wProj.......u_mo
0x64, 0x65, 0x6c, 0x04, 0x20, 0x40, 0x00, 0x80, 0x00, 0x70, 0x02, 0x44, 0x58, 0x42, 0x43, 0x21, // del. @...p.DXBC!
0x99, 0xbc, 0x62, 0x67, 0xb7, 0x95, 0xd6, 0x90, 0x9d, 0x96, 0xc0, 0x0e, 0x98, 0x00, 0xf9, 0x01, // ..bg............
0x00, 0x00, 0x00, 0x70, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x84, // ...p.......,....
0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, 0x00, 0x02, // .......ISGNP....
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .......8........
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x45, // ...............E
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, // ................
0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x42, 0x4c, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x44, 0x49, // .......BLENDINDI
0x43, 0x45, 0x53, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, 0xab, 0x4f, // CES.POSITION...O
0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, // SGN,...........
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, // .......SV_POSITI
0x4f, 0x4e, 0x00, 0x53, 0x48, 0x44, 0x52, 0xb0, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x6c, // ON.SHDR....@...l
0x00, 0x00, 0x00, 0x59, 0x08, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, // ...Y...F. ......
0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x12, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, // ..._..........._
0x00, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, // ...r.......g....
0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x02, // ..........h....
0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, // ...)............
0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, // ........@......8
0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x01, // ...........V....
0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, // ...F. ..........
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x01, // .......2........
0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a, // ...F. ..........
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, // ...............F
0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x01, // .......2........
0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, // ...F. ..........
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, // ...............F
0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, 0x00, // ...F.......F. ..
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, // ...............8
0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x00, // ...........V....
0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, // ...F. .........2
0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, // ...........F. ..
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, // ...............F
0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x01, // .......2........
0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, // ...F. ..........
0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, // .......F.......2
0x00, 0x00, 0x0a, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, // .... ......F. ..
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, // ...............F
0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x0e, 0x00, 0x01, // .......>........
0x00, 0x40, 0x08, // .@.
};
static const uint8_t vs_debugdraw_fill_mtl[555] =
static const uint8_t vs_debugdraw_fill_mtl[650] =
{
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x02, 0x00, 0x00, 0x75, 0x73, // VSH...........us
0x56, 0x53, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x02, 0x00, 0x00, 0x75, 0x73, // VSH.......{...us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // . float3 a_posi
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, // tion [[attribute
0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, // (0)]];.};.struct
0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, // xlatMtlShaderOu
0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, // tput {. float4
0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, // gl_Position [[po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, // sition]];.};.str
0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, // uct xlatMtlShade
0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, // rUniform {. flo
0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, // at4x4 u_modelVie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, // wProj;.};.vertex
0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, // xlatMtlShaderOu
0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, // tput xlatMtlMain
0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, // (xlatMtlShaderI
0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, // nput _mtl_i [[st
0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, // age_in]], consta
0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, // nt xlatMtlShader
0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, // Uniform& _mtl_u
0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, // [[buffer(0)]]).{
0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, // . xlatMtlShader
0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, // Output _mtl_o;.
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // float4 tmpvar_1
0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, // ;. tmpvar_1.w =
0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // 1.0;. tmpvar_1
0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, // .xyz = _mtl_i.a_
0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // position;. _mtl
0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, // _o.gl_Position =
0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // (_mtl_u.u_model
0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ViewProj * tmpva
0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, // r_1);. return _
0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // mtl_o;.}...
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x61, 0x5f, 0x69, 0x6e, 0x64, 0x69, // . float4 a_indi
0x63, 0x65, 0x73, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, // ces [[attribute(
0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, // 0)]];. float3 a
0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, // _position [[attr
0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, // ibute(1)]];.};.s
0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, // truct xlatMtlSha
0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, // derOutput {. fl
0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, // oat4 gl_Position
0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, // [[position]];.}
0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // ;.struct xlatMtl
0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, // ShaderUniform {.
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, // float4x4 u_vie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, // wProj;. float4x
0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x33, 0x32, 0x5d, 0x3b, 0x0a, 0x7d, // 4 u_model[32];.}
0x3b, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // ;.vertex xlatMtl
0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, // ShaderOutput xla
0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // tMtlMain (xlatMt
0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, // lShaderInput _mt
0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, // l_i [[stage_in]]
0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, // , constant xlatM
0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, // tlShaderUniform&
0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, // _mtl_u [[buffer
0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, // (0)]]).{. xlatM
0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, // tlShaderOutput _
0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, // mtl_o;. float4
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // tmpvar_1;. tmpv
0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, // ar_1.w = 1.0;.
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, // tmpvar_1.xyz = _
0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, // mtl_i.a_position
0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, // ;. _mtl_o.gl_Po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, // sition = (_mtl_u
0x2e, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x28, 0x5f, // .u_viewProj * (_
0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x69, 0x6e, // mtl_u.u_model[in
0x74, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, // t(_mtl_i.a_indic
0x65, 0x73, 0x2e, 0x78, 0x29, 0x5d, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // es.x)] * tmpvar_
0x31, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, // 1));. return _m
0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // tl_o;.}...
};

View File

@ -1,4 +1,4 @@
$input a_position
$input a_position, a_indices
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
@ -9,5 +9,6 @@ $input a_position
void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
vec4 model = mul(u_model[int(a_indices.x)], vec4(a_position, 1.0) );
gl_Position = mul(u_viewProj, model);
}

View File

@ -1,195 +1,198 @@
static const uint8_t vs_debugdraw_fill_lit_glsl[613] =
static const uint8_t vs_debugdraw_fill_lit_glsl[532] =
{
0x56, 0x53, 0x48, 0x04, 0x0f, 0xc8, 0x56, 0x5f, 0x03, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH...V_...u_mod
0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x20, 0x00, 0x0b, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // el. .. ..u_model
0x56, 0x69, 0x65, 0x77, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // View.......u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, // elViewProj......
0x20, 0x02, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, // ...attribute hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, // ghp vec3 a_posit
0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, // ion;.varying hig
0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x76, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x3b, 0x0a, // hp vec3 v_view;.
0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, // varying highp ve
0x63, 0x33, 0x20, 0x76, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, // c3 v_world;.unif
0x56, 0x53, 0x48, 0x04, 0x0f, 0xc8, 0x56, 0x5f, 0x03, 0x00, 0x06, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH...V_...u_vie
0x77, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, // w.......u_viewPr
0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // oj.......u_model
0x04, 0x20, 0x00, 0x00, 0x20, 0x00, 0xd9, 0x01, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, // . .. .....attrib
0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, // ute highp vec4 a
0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, // _indices;.attrib
0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, // ute highp vec3 a
0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, // _position;.varyi
0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x76, 0x5f, // ng highp vec3 v_
0x76, 0x69, 0x65, 0x77, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, // view;.varying hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x76, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, // ghp vec3 v_world
0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, // ;.uniform highp
0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x3b, 0x0a, 0x75, 0x6e, 0x69, // mat4 u_view;.uni
0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, // form highp mat4
0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, // u_viewProj;.unif
0x6f, 0x72, 0x6d, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // orm mat4 u_model
0x5b, 0x33, 0x32, 0x5d, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, // [32];.uniform hi
0x67, 0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // ghp mat4 u_model
0x56, 0x69, 0x65, 0x77, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, // View;.uniform hi
0x67, 0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // ghp mat4 u_model
0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, // ViewProj;.void m
0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // ain ().{. highp
0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, // vec4 tmpvar_1;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, // tmpvar_1.w = 1
0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, // .0;. tmpvar_1.x
0x79, 0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, // yz = a_position;
0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, // . gl_Position =
0x20, 0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, // (u_modelViewPro
0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, // j * tmpvar_1);.
0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, // highp vec4 tmpv
0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // ar_2;. tmpvar_2
0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // .w = 1.0;. tmpv
0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, // ar_2.xyz = a_pos
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x20, // ition;. v_view
0x3d, 0x20, 0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x20, 0x2a, // = (u_modelView *
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, // tmpvar_2).xyz;.
0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, // highp vec4 tmp
0x76, 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // var_3;. tmpvar_
0x33, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, // 3.w = 1.0;. tmp
0x76, 0x61, 0x72, 0x5f, 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, // var_3.xyz = a_po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x77, 0x6f, 0x72, 0x6c, // sition;. v_worl
0x64, 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x30, 0x5d, 0x20, // d = (u_model[0]
0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, // * tmpvar_3).xyz;
0x0a, 0x7d, 0x0a, 0x0a, 0x00, // .}...
0x5b, 0x33, 0x32, 0x5d, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, // [32];.void main
0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, // ().{. highp vec
0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 4 tmpvar_1;. tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, // pvar_1.w = 1.0;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, // tmpvar_1.xyz =
0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x68, // a_position;. h
0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // ighp vec4 tmpvar
0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x3d, // _2;. tmpvar_2 =
0x20, 0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x69, 0x6e, 0x74, 0x28, 0x61, 0x5f, // (u_model[int(a_
0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x78, 0x29, 0x5d, 0x20, 0x2a, 0x20, 0x74, 0x6d, // indices.x)] * tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, // pvar_1);. gl_Po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, // sition = (u_view
0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, // Proj * tmpvar_2)
0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, // ;. v_view = (u_
0x76, 0x69, 0x65, 0x77, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, // view * tmpvar_2)
0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x20, // .xyz;. v_world
0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, // = tmpvar_2.xyz;.
0x7d, 0x0a, 0x0a, 0x00, // }...
};
static const uint8_t vs_debugdraw_fill_lit_dx9[563] =
static const uint8_t vs_debugdraw_fill_lit_dx9[645] =
{
0x56, 0x53, 0x48, 0x04, 0x0f, 0xc8, 0x56, 0x5f, 0x03, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH...V_...u_mod
0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x04, 0x00, 0x0b, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // el. .....u_model
0x56, 0x69, 0x65, 0x77, 0x04, 0x01, 0x04, 0x00, 0x04, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // View.......u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x08, 0x00, 0x04, 0x00, // elViewProj......
0xf0, 0x01, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x37, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, // ........7.CTAB..
0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, // ................
0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, // ..........X.....
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, // ......`.......p.
0x00, 0x00, 0x02, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, // ..........|.....
0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7c, 0x00, // ..............|.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x00, 0x03, 0x00, // ......u_model...
0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, // ...... .......u_
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, // modelView.......
0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, // ..........u_mode
0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x76, 0x73, 0x5f, 0x33, 0x5f, 0x30, // lViewProj.vs_3_0
0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, // .Microsoft (R) H
0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, // LSL Shader Compi
0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, // ler 10.0.10011.1
0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, // 6384............
0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, 0x1f, 0x00, // ................
0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x07, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, // ................
0x01, 0x80, 0x02, 0x00, 0x07, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x09, 0x00, // ................
0xe4, 0xa0, 0x00, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x08, 0x00, // ....U...........
0xe4, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
0x0f, 0x80, 0x0a, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, // ................
0x00, 0x03, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x0b, 0x00, 0xe4, 0xa0, 0x05, 0x00, // ................
0x00, 0x03, 0x00, 0x00, 0x07, 0x80, 0x05, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0x55, 0x90, 0x04, 0x00, // ............U...
0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x04, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, // ................
0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x06, 0x00, 0xe4, 0xa0, 0x00, 0x00, // ................
0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0xe0, 0x00, 0x00, // ................
0xe4, 0x80, 0x07, 0x00, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80, 0x01, 0x00, // ................
0xe4, 0xa0, 0x00, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, // ....U...........
0xe4, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
0x07, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, // ................
0x00, 0x03, 0x02, 0x00, 0x07, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0xff, 0xff, // ................
0x00, 0x00, 0x00, // ...
0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x80, 0x00, 0x06, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x04, // el. .....u_view.
0x01, 0x80, 0x00, 0x04, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, // ......u_viewProj
0x04, 0x01, 0x84, 0x00, 0x04, 0x00, 0x4c, 0x02, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x35, 0x00, // ......L.......5.
0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, // CTAB............
0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, // ................
0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, // X...........`...
0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x02, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x00, // ....p...........
0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x02, 0x00, 0x84, 0x00, // x...............
0x04, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, // ....x.......u_mo
0x64, 0x65, 0x6c, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, // del......... ...
0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x00, 0xab, 0x03, 0x00, 0x03, 0x00, // ....u_view......
0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, // ............u_vi
0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x76, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, // ewProj.vs_3_0.Mi
0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, // crosoft (R) HLSL
0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, // Shader Compiler
0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, // 10.0.10011.1638
0x34, 0x00, 0xab, 0xab, 0x51, 0x00, 0x00, 0x05, 0x88, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x40, // 4...Q..........@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, // ................
0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, // ................
0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, // ................
0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x07, 0xe0, 0x1f, 0x00, 0x00, 0x02, // ................
0x05, 0x00, 0x01, 0x80, 0x02, 0x00, 0x07, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, // ................
0x88, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x2e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0xb0, // ................
0x00, 0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0x55, 0x90, // ..............U.
0x01, 0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0x80, // . ..............
0x00, 0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, // . ..............
0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, // ......... ......
0x01, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, // ................
0x00, 0x00, 0xe4, 0x80, 0x03, 0x20, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x05, 0x00, 0x00, 0x03, // ..... ..........
0x01, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x55, 0x80, 0x85, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, // ......U.........
0x01, 0x00, 0x0f, 0x80, 0x84, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe4, 0x80, // ................
0x04, 0x00, 0x00, 0x04, 0x01, 0x00, 0x0f, 0x80, 0x86, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x80, // ................
0x01, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0xe0, 0x87, 0x00, 0xe4, 0xa0, // ................
0x00, 0x00, 0xff, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03, 0x01, 0x00, 0x07, 0x80, // ................
0x00, 0x00, 0x55, 0x80, 0x81, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x01, 0x00, 0x07, 0x80, // ..U.............
0x80, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, // ................
0x01, 0x00, 0x07, 0x80, 0x82, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x80, 0x01, 0x00, 0xe4, 0x80, // ................
0x04, 0x00, 0x00, 0x04, 0x01, 0x00, 0x07, 0xe0, 0x83, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xff, 0x80, // ................
0x01, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x07, 0xe0, 0x00, 0x00, 0xe4, 0x80, // ................
0xff, 0xff, 0x00, 0x00, 0x00, // .....
};
static const uint8_t vs_debugdraw_fill_lit_dx11[808] =
static const uint8_t vs_debugdraw_fill_lit_dx11[944] =
{
0x56, 0x53, 0x48, 0x04, 0x0f, 0xc8, 0x56, 0x5f, 0x03, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH...V_...u_mod
0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x80, 0x00, 0x0b, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // el. .....u_model
0x56, 0x69, 0x65, 0x77, 0x04, 0x00, 0x00, 0x08, 0x04, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // View.......u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x00, 0x40, 0x08, 0x04, 0x00, // elViewProj..@...
0xe0, 0x02, 0x44, 0x58, 0x42, 0x43, 0xda, 0xb8, 0xef, 0x0e, 0x34, 0xc8, 0x8c, 0x2c, 0x06, 0xbc, // ..DXBC....4..,..
0x07, 0x0b, 0x43, 0x58, 0xee, 0x33, 0x01, 0x00, 0x00, 0x00, 0xe0, 0x02, 0x00, 0x00, 0x03, 0x00, // ..CX.3..........
0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x49, 0x53, // ..,...`.......IS
0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, // GN,........... .
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, // ......POSITION..
0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, // ..OSGNh.........
0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, // ..P.............
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x08, // ................
0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, // ................
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, // ..........SV_POS
0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, // ITION.TEXCOORD..
0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0x08, 0x02, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x82, 0x00, // ..SHDR....@.....
0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, // ..Y...F. .......
0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, // .._...r.......g.
0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, // ... ..........e.
0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, // ..r ......e...r
0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, // ......h.......8.
0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x00, 0x00, // ..........V.....
0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x32, 0x00, // ..F. .........2.
0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..........F. ...
0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, // ..............F.
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, // ......2.........
0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0xa6, 0x1a, // ..F. ...........
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......F.........
0x00, 0x08, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, // ... ......F.....
0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x38, 0x00, // ..F. .........8.
0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x00, 0x00, // ..r.......V.....
0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x32, 0x00, // ..F. .........2.
0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, // ..r.......F. ...
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, // ..............F.
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, // ......2...r.....
0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0xa6, 0x1a, // ..F. ...........
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......F.........
0x00, 0x08, 0x72, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, // ..r ......F.....
0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x38, 0x00, // ..F. .........8.
0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x00, 0x00, // ..r.......V.....
0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, // ..F. .........2.
0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, // ..r.......F. ...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, // ..............F.
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, // ......2...r.....
0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x1a, // ..F. ...........
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......F.........
0x00, 0x08, 0x72, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, // ..r ......F.....
0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3e, 0x00, // ..F. .........>.
0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x80, 0x08, // ........
0x56, 0x53, 0x48, 0x04, 0x0f, 0xc8, 0x56, 0x5f, 0x03, 0x00, 0x06, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH...V_...u_vie
0x77, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, // w.......u_viewPr
0x6f, 0x6a, 0x04, 0x00, 0x40, 0x00, 0x04, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // oj..@....u_model
0x04, 0x20, 0x80, 0x00, 0x80, 0x00, 0x70, 0x03, 0x44, 0x58, 0x42, 0x43, 0x4a, 0x63, 0x00, 0x1f, // . ....p.DXBCJc..
0x8c, 0xf0, 0x42, 0x23, 0xf7, 0x2c, 0xd7, 0x55, 0x64, 0x23, 0x64, 0x92, 0x01, 0x00, 0x00, 0x00, // ..B#.,.Ud#d.....
0x70, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, // p.......,.......
0xf4, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ....ISGNP.......
0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....8...........
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, // ............E...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
0x07, 0x07, 0x00, 0x00, 0x42, 0x4c, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x44, 0x49, 0x43, 0x45, 0x53, // ....BLENDINDICES
0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, // .POSITION...OSGN
0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // h...........P...
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, // ................
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ................
0x07, 0x08, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, // ....SV_POSITION.
0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, // TEXCOORD....SHDR
0x74, 0x02, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x59, 0x08, 0x00, 0x04, // t...@.......Y...
0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, // F. ........._...
0x12, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, // ........_...r...
0x01, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....g.... ......
0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ....e...r ......
0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, // e...r ......h...
0x02, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....)...........
0x0a, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // .........@......
0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, // 8...........V...
0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, // ....F. .........
0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, // ........2.......
0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, // ....F. .........
0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, // F.......2.......
0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, // ....F. .........
0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, // F...............
0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x06, // ....F.......F. .
0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, // 8...........V...
0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, // ....F. .........
0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, // 2...........F. .
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, // F.......2.......
0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, // ....F. .........
0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ........F.......
0x32, 0x00, 0x00, 0x0a, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, // 2.... ......F. .
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, // F.......8...r...
0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, // ....V.......F. .
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, // ........2...r...
0x01, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....F. .........
0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ........F.......
0x32, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, // 2...r.......F. .
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x72, 0x20, 0x10, 0x00, // F.......2...r ..
0x01, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // ....F. .........
0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ........F.......
0x36, 0x00, 0x00, 0x05, 0x72, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, // 6...r ......F...
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x0e, 0x00, 0x01, 0x00, 0x80, 0x08, // ....>...........
};
static const uint8_t vs_debugdraw_fill_lit_mtl[898] =
static const uint8_t vs_debugdraw_fill_lit_mtl[829] =
{
0x56, 0x53, 0x48, 0x04, 0x0f, 0xc8, 0x56, 0x5f, 0x00, 0x00, 0x73, 0x03, 0x00, 0x00, 0x75, 0x73, // VSH...V_..s...us
0x56, 0x53, 0x48, 0x04, 0x0f, 0xc8, 0x56, 0x5f, 0x00, 0x00, 0x2e, 0x03, 0x00, 0x00, 0x75, 0x73, // VSH...V_......us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // . float3 a_posi
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, // tion [[attribute
0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, // (0)]];.};.struct
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x61, 0x5f, 0x69, 0x6e, 0x64, 0x69, // . float4 a_indi
0x63, 0x65, 0x73, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, // ces [[attribute(
0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, // 0)]];. float3 a
0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, // _position [[attr
0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, // ibute(1)]];.};.s
0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, // truct xlatMtlSha
0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, // derOutput {. fl
0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, // oat4 gl_Position
0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, // [[position]];.
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x76, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x3b, 0x0a, // float3 v_view;.
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x76, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, // float3 v_world
0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // ;.};.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, // MtlShaderUniform
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, // {. float4x4 u_
0x76, 0x69, 0x65, 0x77, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, // view;. float4x4
0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x20, 0x20, 0x66, // u_viewProj;. f
0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, // loat4x4 u_model[
0x33, 0x32, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x78, // 32];.};.vertex x
0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, // latMtlShaderOutp
0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, // ut xlatMtlMain (
0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, // xlatMtlShaderInp
0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, // ut _mtl_i [[stag
0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, // e_in]], constant
0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, // xlatMtlShaderUn
0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, // iform& _mtl_u [[
0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, // buffer(0)]]).{.
0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, // xlatMtlShaderOu
0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, // tput {. float4
0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, // gl_Position [[po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, // sition]];. floa
0x74, 0x33, 0x20, 0x76, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, // t3 v_view;. flo
0x61, 0x74, 0x33, 0x20, 0x76, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, // at3 v_world;.};.
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // struct xlatMtlSh
0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x20, 0x20, // aderUniform {.
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // float4x4 u_model
0x5b, 0x33, 0x32, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, // [32];. float4x4
0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x3b, 0x0a, 0x20, 0x20, // u_modelView;.
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // float4x4 u_model
0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, 0x72, // ViewProj;.};.ver
0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, // tex xlatMtlShade
0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, // rOutput xlatMtlM
0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, // ain (xlatMtlShad
0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, // erInput _mtl_i [
0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, // [stage_in]], con
0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, // stant xlatMtlSha
0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // derUniform& _mtl
0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, // _u [[buffer(0)]]
0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, // ).{. xlatMtlSha
0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, // derOutput _mtl_o
0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ;. float4 tmpva
0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, // r_1;. tmpvar_1.
0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // w = 1.0;. tmpva
0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, // r_1.xyz = _mtl_i
0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, // .a_position;. _
0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, // mtl_o.gl_Positio
0x6e, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, 0x6f, // n = (_mtl_u.u_mo
0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, // delViewProj * tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // pvar_1);. float
0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 4 tmpvar_2;. tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, // pvar_2.w = 1.0;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, // tmpvar_2.xyz =
0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, // _mtl_i.a_positi
0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x76, // on;. _mtl_o.v_v
0x69, 0x65, 0x77, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, // iew = (_mtl_u.u_
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, // modelView * tmpv
0x61, 0x72, 0x5f, 0x32, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, // ar_2).xyz;. flo
0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, // at4 tmpvar_3;.
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, // tmpvar_3.w = 1.0
0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x2e, 0x78, 0x79, 0x7a, // ;. tmpvar_3.xyz
0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // = _mtl_i.a_posi
0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, // tion;. _mtl_o.v
0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, // _world = (_mtl_u
0x2e, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x30, 0x5d, 0x20, 0x2a, 0x20, 0x74, 0x6d, // .u_model[0] * tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x72, // pvar_3).xyz;. r
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, // eturn _mtl_o;.}.
0x0a, 0x00, // ..
0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, // tput _mtl_o;. f
0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, // loat4 tmpvar_1;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, // tmpvar_1.w = 1
0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, // .0;. tmpvar_1.x
0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, // yz = _mtl_i.a_po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, // sition;. float4
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, // tmpvar_2;. tmp
0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, // var_2 = (_mtl_u.
0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x69, 0x6e, 0x74, 0x28, 0x5f, 0x6d, 0x74, 0x6c, // u_model[int(_mtl
0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x78, 0x29, 0x5d, // _i.a_indices.x)]
0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, // * tmpvar_1);.
0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, // _mtl_o.gl_Positi
0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x76, // on = (_mtl_u.u_v
0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // iewProj * tmpvar
0x5f, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, // _2);. _mtl_o.v_
0x76, 0x69, 0x65, 0x77, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, // view = (_mtl_u.u
0x5f, 0x76, 0x69, 0x65, 0x77, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // _view * tmpvar_2
0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, // ).xyz;. _mtl_o.
0x76, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // v_world = tmpvar
0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, // _2.xyz;. return
0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // _mtl_o;.}...
};

View File

@ -1,4 +1,4 @@
$input a_position
$input a_position, a_indices
$output v_view, v_world
/*
@ -10,7 +10,8 @@ $output v_view, v_world
void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
v_view = mul(u_modelView, vec4(a_position, 1.0) ).xyz;
v_world = mul(u_model[0], vec4(a_position, 1.0) ).xyz;
vec4 world = mul(u_model[int(a_indices.x)], vec4(a_position, 1.0) );
gl_Position = mul(u_viewProj, world);
v_view = mul(u_view, world).xyz;
v_world = world.xyz;
}

View File

@ -473,25 +473,19 @@ BX_PRAGMA_DIAGNOSTIC_POP();
const MouseEvent* mouse = static_cast<const MouseEvent*>(ev);
handle = mouse->m_handle;
if (mouse->m_move)
{
inputSetMousePos(mouse->m_mx, mouse->m_my, mouse->m_mz);
}
else
if (!mouse->m_move)
{
inputSetMouseButtonState(mouse->m_button, mouse->m_down);
}
if (NULL != _mouse
&& !mouseLock)
{
if (mouse->m_move)
{
_mouse->m_mx = mouse->m_mx;
_mouse->m_my = mouse->m_my;
_mouse->m_mz = mouse->m_mz;
}
else
if (!mouse->m_move)
{
_mouse->m_buttons[mouse->m_button] = mouse->m_down;
}

View File

@ -82,7 +82,6 @@ namespace entry
{
Context()
: m_window(NULL)
, m_count(0)
{
memset(m_value, 0, sizeof(m_value) );
@ -297,44 +296,36 @@ namespace entry
int32_t action = (actionBits & AMOTION_EVENT_ACTION_MASK);
int32_t index = (actionBits & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
count = m_count;
// Simulate left mouse click with 1st touch and right mouse click with 2nd touch. ignore other touchs
if (count < 2)
{
switch (action)
{
case AMOTION_EVENT_ACTION_DOWN:
case AMOTION_EVENT_ACTION_POINTER_DOWN:
m_count++;
m_eventQueue.postMouseEvent(defaultWindow
, (int32_t)mx
, (int32_t)my
, 0
, action == AMOTION_EVENT_ACTION_DOWN ? MouseButton::Left : MouseButton::Right
, true
);
break;
case AMOTION_EVENT_ACTION_UP:
case AMOTION_EVENT_ACTION_POINTER_UP:
m_count--;
m_eventQueue.postMouseEvent(defaultWindow
, (int32_t)mx
, (int32_t)my
, 0
, action == AMOTION_EVENT_ACTION_UP ? MouseButton::Left : MouseButton::Right
, false
);
break;
default:
break;
}
if (count != m_count)
{
m_eventQueue.postMouseEvent(defaultWindow
, (int32_t)mx
, (int32_t)my
, 0
, 1 == count ? MouseButton::Left : MouseButton::Right
, false
);
if (0 != m_count)
{
m_eventQueue.postMouseEvent(defaultWindow
, (int32_t)mx
, (int32_t)my
, 0
, 1 == m_count ? MouseButton::Left : MouseButton::Right
, true
);
}
}
switch (action)
@ -405,7 +396,6 @@ namespace entry
ANativeWindow* m_window;
android_app* m_app;
int32_t m_count;
int32_t m_value[GamepadAxis::Count];
int32_t m_deadzone[GamepadAxis::Count];
};

View File

@ -312,7 +312,7 @@ static void* m_device = NULL;
[m_window makeKeyAndVisible];
//float scaleFactor = [[UIScreen mainScreen] scale]; // should use this, but ui is too small on ipad retina
//float scaleFactor = [[UIScreen mainScreen] scale]; // should use this, but needs to further pass the value to the `nvgBeginFrame()` call's `devicePixelRatio` parameter in `ExampleNanoVG` class' `update()` method so it can actually work properly.
float scaleFactor = 1.0f;
[m_view setContentScaleFactor: scaleFactor ];

View File

@ -185,9 +185,9 @@ static const uint8_t fs_font_distance_field_dx11[1053] =
0x00, 0x36, 0x00, 0x00, 0x05, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, 0x10, // .6...r ......F..
0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // .....>.......
};
static const uint8_t fs_font_distance_field_mtl[1492] =
static const uint8_t fs_font_distance_field_mtl[1493] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xc5, 0x05, 0x00, 0x00, 0x75, 0x73, // FSH...........us
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xc6, 0x05, 0x00, 0x00, 0x75, 0x73, // FSH...........us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
@ -240,45 +240,45 @@ static const uint8_t fs_font_distance_field_mtl[1492] =
0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // mtl_i.v_texcoord
0x30, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, // 0.xyz);. float3
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, // tmpvar_5;. tmp
0x76, 0x61, 0x72, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x64, 0x66, 0x64, 0x79, 0x28, 0x5f, 0x6d, 0x74, // var_5 = dfdy(_mt
0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, // l_i.v_texcoord0.
0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x6d, // xyz);. float tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // pvar_6;. tmpvar
0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x38, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x28, 0x73, 0x71, 0x72, // _6 = (8.0 * (sqr
0x74, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, // t(. dot (tmpv
0x61, 0x72, 0x5f, 0x34, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x0a, // ar_4, tmpvar_4).
0x20, 0x20, 0x29, 0x20, 0x2b, 0x20, 0x73, 0x71, 0x72, 0x74, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, // ) + sqrt(.
0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x2c, 0x20, 0x74, // dot (tmpvar_5, t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x29, 0x29, 0x3b, 0x0a, // mpvar_5). )));.
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x37, 0x3b, // float edge0_7;
0x0a, 0x20, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x37, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, // . edge0_7 = (0.
0x35, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x3b, 0x0a, 0x20, // 5 - tmpvar_6);.
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x65, 0x64, 0x67, 0x65, 0x31, 0x5f, 0x38, 0x3b, 0x0a, // float edge1_8;.
0x20, 0x20, 0x65, 0x64, 0x67, 0x65, 0x31, 0x5f, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, 0x35, // edge1_8 = (0.5
0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x3b, 0x0a, 0x20, 0x20, // + tmpvar_6);.
0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x3b, 0x0a, 0x20, // half tmpvar_9;.
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, 0x6d, // tmpvar_9 = clam
0x70, 0x20, 0x28, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, // p (((half)((floa
0x74, 0x29, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, // t)((half)((float
0x29, 0x72, 0x67, 0x62, 0x61, 0x5f, 0x31, 0x5b, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, // )rgba_1[tmpvar_3
0x5d, 0x20, 0x2d, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x37, 0x29, 0x29, 0x20, 0x2f, 0x20, // ] - edge0_7)) /
0x28, 0x65, 0x64, 0x67, 0x65, 0x31, 0x5f, 0x38, 0x20, 0x2d, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, // (edge1_8 - edge0
0x5f, 0x37, 0x29, 0x29, 0x29, 0x2c, 0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x30, 0x2e, 0x30, // _7))), (half)0.0
0x2c, 0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, // , (half)1.0);.
0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x3b, // half4 tmpvar_10;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x2e, 0x78, 0x79, 0x7a, // . tmpvar_10.xyz
0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, // = half3(_mtl_i.
0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, // v_color0.xyz);.
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x28, // tmpvar_10.w = (
0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, // (half)(_mtl_i.v_
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, 0x20, 0x2a, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, // color0.w * (floa
0x74, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x2a, 0x20, 0x28, 0x74, // t)(tmpvar_9 * (t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x2a, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x28, // mpvar_9 * . (
0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x33, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x28, 0x68, 0x61, // (half)3.0 - ((ha
0x6c, 0x66, 0x29, 0x32, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // lf)2.0 * tmpvar_
0x39, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, // 9)). ))));. _m
0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, // tl_o.gl_FragColo
0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x3b, 0x0a, 0x20, // r = tmpvar_10;.
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, // return _mtl_o;.
0x7d, 0x0a, 0x0a, 0x00, // }...
0x76, 0x61, 0x72, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x64, 0x66, 0x64, 0x79, 0x28, 0x2d, 0x5f, 0x6d, // var_5 = dfdy(-_m
0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // tl_i.v_texcoord0
0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, // .xyz);. float t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // mpvar_6;. tmpva
0x72, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x38, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x28, 0x73, 0x71, // r_6 = (8.0 * (sq
0x72, 0x74, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x6d, 0x70, // rt(. dot (tmp
0x76, 0x61, 0x72, 0x5f, 0x34, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, // var_4, tmpvar_4)
0x0a, 0x20, 0x20, 0x29, 0x20, 0x2b, 0x20, 0x73, 0x71, 0x72, 0x74, 0x28, 0x0a, 0x20, 0x20, 0x20, // . ) + sqrt(.
0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x2c, 0x20, // dot (tmpvar_5,
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x29, 0x29, 0x3b, // tmpvar_5). )));
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x37, // . float edge0_7
0x3b, 0x0a, 0x20, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x37, 0x20, 0x3d, 0x20, 0x28, 0x30, // ;. edge0_7 = (0
0x2e, 0x35, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x3b, 0x0a, // .5 - tmpvar_6);.
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x65, 0x64, 0x67, 0x65, 0x31, 0x5f, 0x38, 0x3b, // float edge1_8;
0x0a, 0x20, 0x20, 0x65, 0x64, 0x67, 0x65, 0x31, 0x5f, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, // . edge1_8 = (0.
0x35, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x3b, 0x0a, 0x20, // 5 + tmpvar_6);.
0x20, 0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x3b, 0x0a, // half tmpvar_9;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, // tmpvar_9 = cla
0x6d, 0x70, 0x20, 0x28, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, // mp (((half)((flo
0x61, 0x74, 0x29, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, // at)((half)((floa
0x74, 0x29, 0x72, 0x67, 0x62, 0x61, 0x5f, 0x31, 0x5b, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // t)rgba_1[tmpvar_
0x33, 0x5d, 0x20, 0x2d, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x37, 0x29, 0x29, 0x20, 0x2f, // 3] - edge0_7)) /
0x20, 0x28, 0x65, 0x64, 0x67, 0x65, 0x31, 0x5f, 0x38, 0x20, 0x2d, 0x20, 0x65, 0x64, 0x67, 0x65, // (edge1_8 - edge
0x30, 0x5f, 0x37, 0x29, 0x29, 0x29, 0x2c, 0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x30, 0x2e, // 0_7))), (half)0.
0x30, 0x2c, 0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, // 0, (half)1.0);.
0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, // half4 tmpvar_10
0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x2e, 0x78, 0x79, // ;. tmpvar_10.xy
0x7a, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, // z = half3(_mtl_i
0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, // .v_color0.xyz);.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x2e, 0x77, 0x20, 0x3d, 0x20, // tmpvar_10.w =
0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, // ((half)(_mtl_i.v
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, 0x20, 0x2a, 0x20, 0x28, 0x66, 0x6c, 0x6f, // _color0.w * (flo
0x61, 0x74, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x2a, 0x20, 0x28, // at)(tmpvar_9 * (
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x2a, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, // tmpvar_9 * .
0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x33, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x28, 0x68, // ((half)3.0 - ((h
0x61, 0x6c, 0x66, 0x29, 0x32, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // alf)2.0 * tmpvar
0x5f, 0x39, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, // _9)). ))));. _
0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, // mtl_o.gl_FragCol
0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x3b, 0x0a, // or = tmpvar_10;.
0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, // return _mtl_o;
0x0a, 0x7d, 0x0a, 0x0a, 0x00, // .}...
};

View File

@ -226,9 +226,9 @@ static const uint8_t fs_font_distance_field_subpixel_dx11[1305] =
0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x1f, 0x10, 0x00, 0x01, 0x00, 0x00, // .F..............
0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // .>.......
};
static const uint8_t fs_font_distance_field_subpixel_mtl[1945] =
static const uint8_t fs_font_distance_field_subpixel_mtl[1946] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0x8a, 0x07, 0x00, 0x00, 0x75, 0x73, // FSH...........us
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0x8b, 0x07, 0x00, 0x00, 0x75, 0x73, // FSH...........us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
@ -267,87 +267,87 @@ static const uint8_t fs_font_distance_field_subpixel_mtl[1945] =
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, // excoord0.xyz);.
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, // float3 tmpvar_3
0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x20, 0x3d, 0x20, 0x64, // ;. tmpvar_3 = d
0x66, 0x64, 0x79, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, // fdy(_mtl_i.v_tex
0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, // coord0.xyz);. f
0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x3b, 0x0a, // loat3 tmpvar_4;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, // tmpvar_4 = (0.
0x31, 0x36, 0x36, 0x36, 0x36, 0x37, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // 166667 * tmpvar_
0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x74, 0x6d, 0x70, // 2);. float3 tmp
0x76, 0x61, 0x72, 0x5f, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // var_5;. tmpvar_
0x35, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, // 5 = (_mtl_i.v_te
0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2d, 0x20, 0x74, 0x6d, // xcoord0.xyz - tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // pvar_4);. float
0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 3 tmpvar_6;. tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, // pvar_6 = (_mtl_i
0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, 0x7a, // .v_texcoord0.xyz
0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, // + tmpvar_4);.
0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x3b, 0x0a, // half4 tmpvar_7;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, // tmpvar_7 = hal
0x66, 0x34, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, 0x61, // f4(s_texColor.sa
0x6d, 0x70, 0x6c, 0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, // mple(_mtlsmp_s_t
0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, // exColor, (float3
0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, // )(tmpvar_5)));.
0x20, 0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x3b, 0x0a, // half tmpvar_8;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, // tmpvar_8 = ((h
0x61, 0x6c, 0x66, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x2e, 0x7a, 0x79, 0x78, // alf)tmpvar_7.zyx
0x77, 0x5b, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x5d, 0x29, 0x3b, 0x0a, 0x20, 0x20, // w[tmpvar_1]);.
0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x3b, 0x0a, // half4 tmpvar_9;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, // tmpvar_9 = hal
0x66, 0x34, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, 0x61, // f4(s_texColor.sa
0x6d, 0x70, 0x6c, 0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, // mple(_mtlsmp_s_t
0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, // exColor, (float3
0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, // )(tmpvar_6)));.
0x20, 0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x3b, // half tmpvar_10;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x20, 0x3d, 0x20, 0x28, // . tmpvar_10 = (
0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x2e, 0x7a, // (half)tmpvar_9.z
0x79, 0x78, 0x77, 0x5b, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x5d, 0x29, 0x3b, 0x0a, // yxw[tmpvar_1]);.
0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x31, // half tmpvar_11
0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x31, 0x20, 0x3d, 0x20, // ;. tmpvar_11 =
0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x30, 0x2e, 0x35, 0x20, 0x2a, 0x20, 0x28, 0x74, 0x6d, // ((half)0.5 * (tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // pvar_8 + tmpvar_
0x31, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x6d, // 10));. float tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // pvar_12;. tmpva
0x72, 0x5f, 0x31, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x38, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x28, 0x73, // r_12 = (8.0 * (s
0x71, 0x72, 0x74, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x6d, // qrt(. dot (tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // pvar_2, tmpvar_2
0x29, 0x0a, 0x20, 0x20, 0x29, 0x20, 0x2b, 0x20, 0x73, 0x71, 0x72, 0x74, 0x28, 0x0a, 0x20, 0x20, // ). ) + sqrt(.
0x20, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x2c, // dot (tmpvar_3,
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x29, 0x29, // tmpvar_3). )))
0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // ;. half3 tmpvar
0x5f, 0x31, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, // _13;. tmpvar_13
0x2e, 0x78, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x3b, 0x0a, 0x20, // .x = tmpvar_8;.
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x74, // tmpvar_13.y = t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // mpvar_11;. tmpv
0x61, 0x72, 0x5f, 0x31, 0x33, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // ar_13.z = tmpvar
0x5f, 0x31, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x65, 0x64, 0x67, // _10;. float edg
0x65, 0x30, 0x5f, 0x31, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x31, // e0_14;. edge0_1
0x34, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, 0x35, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // 4 = (0.5 - tmpva
0x72, 0x5f, 0x31, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x65, // r_12);. float e
0x64, 0x67, 0x65, 0x31, 0x5f, 0x31, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x65, 0x64, 0x67, 0x65, 0x31, // dge1_15;. edge1
0x5f, 0x31, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, 0x35, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, // _15 = (0.5 + tmp
0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x33, // var_12);. half3
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // tmpvar_16;. tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x20, // pvar_16 = clamp
0x28, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, // (((half3)((float
0x33, 0x29, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, // 3)((half3)((floa
0x74, 0x33, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x20, 0x2d, 0x20, 0x65, // t3)tmpvar_13 - e
0x64, 0x67, 0x65, 0x30, 0x5f, 0x31, 0x34, 0x29, 0x29, 0x20, 0x2f, 0x20, 0x28, 0x65, 0x64, 0x67, // dge0_14)) / (edg
0x65, 0x31, 0x5f, 0x31, 0x35, 0x20, 0x2d, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x31, 0x34, // e1_15 - edge0_14
0x29, 0x29, 0x29, 0x2c, 0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x30, 0x2e, 0x30, 0x2c, 0x20, // ))), (half)0.0,
0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, // (half)1.0);. _m
0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, // tl_o.gl_FragColo
0x72, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x29, // r.xyz = ((half3)
0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // ((float3)(tmpvar
0x5f, 0x31, 0x36, 0x20, 0x2a, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, // _16 * (tmpvar_16
0x20, 0x2a, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x33, // * . ((half)3
0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x32, 0x2e, 0x30, 0x20, // .0 - ((half)2.0
0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x29, 0x29, 0x0a, 0x20, 0x20, // * tmpvar_16)).
0x29, 0x29, 0x20, 0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, // )) * _mtl_i.v_co
0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // lor0.w));. _mtl
0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, // _o.gl_FragColor.
0x77, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, // w = ((half)((flo
0x61, 0x74, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x31, 0x20, 0x2a, 0x20, 0x5f, // at)tmpvar_11 * _
0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, // mtl_i.v_color0.w
0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, // ));. return _mt
0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // l_o;.}...
0x66, 0x64, 0x79, 0x28, 0x2d, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, // fdy(-_mtl_i.v_te
0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, // xcoord0.xyz);.
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x3b, // float3 tmpvar_4;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x30, // . tmpvar_4 = (0
0x2e, 0x31, 0x36, 0x36, 0x36, 0x36, 0x37, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // .166667 * tmpvar
0x5f, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x74, 0x6d, // _2);. float3 tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // pvar_5;. tmpvar
0x5f, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, // _5 = (_mtl_i.v_t
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2d, 0x20, 0x74, // excoord0.xyz - t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, // mpvar_4);. floa
0x74, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x74, // t3 tmpvar_6;. t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // mpvar_6 = (_mtl_
0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, // i.v_texcoord0.xy
0x7a, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x3b, 0x0a, 0x20, // z + tmpvar_4);.
0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x3b, // half4 tmpvar_7;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x20, 0x3d, 0x20, 0x68, 0x61, // . tmpvar_7 = ha
0x6c, 0x66, 0x34, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, // lf4(s_texColor.s
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, // ample(_mtlsmp_s_
0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, // texColor, (float
0x33, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x29, 0x29, 0x29, 0x3b, 0x0a, // 3)(tmpvar_5)));.
0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x3b, // half tmpvar_8;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x28, // . tmpvar_8 = ((
0x68, 0x61, 0x6c, 0x66, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x2e, 0x7a, 0x79, // half)tmpvar_7.zy
0x78, 0x77, 0x5b, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x5d, 0x29, 0x3b, 0x0a, 0x20, // xw[tmpvar_1]);.
0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x3b, // half4 tmpvar_9;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x3d, 0x20, 0x68, 0x61, // . tmpvar_9 = ha
0x6c, 0x66, 0x34, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, // lf4(s_texColor.s
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, // ample(_mtlsmp_s_
0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, // texColor, (float
0x33, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x29, 0x29, 0x3b, 0x0a, // 3)(tmpvar_6)));.
0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, // half tmpvar_10
0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x20, 0x3d, 0x20, // ;. tmpvar_10 =
0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x2e, // ((half)tmpvar_9.
0x7a, 0x79, 0x78, 0x77, 0x5b, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x5d, 0x29, 0x3b, // zyxw[tmpvar_1]);
0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // . half tmpvar_1
0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x31, 0x20, 0x3d, // 1;. tmpvar_11 =
0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x30, 0x2e, 0x35, 0x20, 0x2a, 0x20, 0x28, 0x74, // ((half)0.5 * (t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // mpvar_8 + tmpvar
0x5f, 0x31, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, // _10));. float t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // mpvar_12;. tmpv
0x61, 0x72, 0x5f, 0x31, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x38, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x28, // ar_12 = (8.0 * (
0x73, 0x71, 0x72, 0x74, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, // sqrt(. dot (t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // mpvar_2, tmpvar_
0x32, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x20, 0x2b, 0x20, 0x73, 0x71, 0x72, 0x74, 0x28, 0x0a, 0x20, // 2). ) + sqrt(.
0x20, 0x20, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, // dot (tmpvar_3
0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x29, // , tmpvar_3). ))
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // );. half3 tmpva
0x72, 0x5f, 0x31, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // r_13;. tmpvar_1
0x33, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x3b, 0x0a, // 3.x = tmpvar_8;.
0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x2e, 0x79, 0x20, 0x3d, 0x20, // tmpvar_13.y =
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, // tmpvar_11;. tmp
0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // var_13.z = tmpva
0x72, 0x5f, 0x31, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x65, 0x64, // r_10;. float ed
0x67, 0x65, 0x30, 0x5f, 0x31, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, // ge0_14;. edge0_
0x31, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, 0x35, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, // 14 = (0.5 - tmpv
0x61, 0x72, 0x5f, 0x31, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, // ar_12);. float
0x65, 0x64, 0x67, 0x65, 0x31, 0x5f, 0x31, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x65, 0x64, 0x67, 0x65, // edge1_15;. edge
0x31, 0x5f, 0x31, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, 0x35, 0x20, 0x2b, 0x20, 0x74, 0x6d, // 1_15 = (0.5 + tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, // pvar_12);. half
0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x74, // 3 tmpvar_16;. t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, 0x6d, 0x70, // mpvar_16 = clamp
0x20, 0x28, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, // (((half3)((floa
0x74, 0x33, 0x29, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x33, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, // t3)((half3)((flo
0x61, 0x74, 0x33, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x20, 0x2d, 0x20, // at3)tmpvar_13 -
0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x31, 0x34, 0x29, 0x29, 0x20, 0x2f, 0x20, 0x28, 0x65, 0x64, // edge0_14)) / (ed
0x67, 0x65, 0x31, 0x5f, 0x31, 0x35, 0x20, 0x2d, 0x20, 0x65, 0x64, 0x67, 0x65, 0x30, 0x5f, 0x31, // ge1_15 - edge0_1
0x34, 0x29, 0x29, 0x29, 0x2c, 0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x30, 0x2e, 0x30, 0x2c, // 4))), (half)0.0,
0x20, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, // (half)1.0);. _
0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, // mtl_o.gl_FragCol
0x6f, 0x72, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x33, // or.xyz = ((half3
0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, // )((float3)(tmpva
0x72, 0x5f, 0x31, 0x36, 0x20, 0x2a, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // r_16 * (tmpvar_1
0x36, 0x20, 0x2a, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, // 6 * . ((half)
0x33, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x32, 0x2e, 0x30, // 3.0 - ((half)2.0
0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x29, 0x29, 0x0a, 0x20, // * tmpvar_16)).
0x20, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, // )) * _mtl_i.v_c
0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, // olor0.w));. _mt
0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, // l_o.gl_FragColor
0x2e, 0x77, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x28, 0x66, 0x6c, // .w = ((half)((fl
0x6f, 0x61, 0x74, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x31, 0x20, 0x2a, 0x20, // oat)tmpvar_11 *
0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, // _mtl_i.v_color0.
0x77, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, // w));. return _m
0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // tl_o;.}...
};

View File

@ -1488,7 +1488,7 @@ struct Imgui
}
}
uint8_t tabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint8_t _nTabs, uint8_t _nEnabled, va_list _argList)
uint8_t tabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint32_t _nTabs, uint32_t _nEnabled, va_list _argList)
{
const char* titles[16];
bool tabEnabled[16];
@ -3469,7 +3469,7 @@ void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled, Im
s_imgui.input(_label, _str, _len, _enabled, _align, _r);
}
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint8_t _nTabs, uint8_t _nEnabled, ...)
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint32_t _nTabs, uint32_t _nEnabled, ...)
{
va_list argList;
va_start(argList, _nEnabled);
@ -3479,7 +3479,7 @@ uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int
return result;
}
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint8_t _nTabs, ...)
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint32_t _nTabs, ...)
{
va_list argList;
va_start(argList, _nTabs);

View File

@ -190,8 +190,8 @@ void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled = t
/// _nEnabled - Number of specified 'enabled' flags. All other unspecified tabs are considered enabled by default.
/// In the above example, there are 2 enabled flags: 'Tab0' is specified as enabled and 'Tab1' is specified as disabled.
/// Tab2 is unspecified and therefore is treated as enabled.
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint8_t _nTabs, uint8_t _nEnabled, ...);
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint8_t _nTabs, ...);
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint32_t _nTabs, uint32_t _nEnabled, ...);
uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int32_t _height, int32_t _r, uint32_t _nTabs, ...);
uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...);
#define imguiChoose(...) imguiChooseUseMacroInstead(__VA_ARGS__, NULL)

View File

@ -339,7 +339,7 @@ void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float dev
nvg__setDevicePixelRatio(ctx, devicePixelRatio);
ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight);
ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight, devicePixelRatio);
ctx->drawCallCount = 0;
ctx->fillTriCount = 0;

View File

@ -19,6 +19,8 @@
#ifndef NANOVG_H
#define NANOVG_H
#include "nanovg_bgfx.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -588,7 +590,7 @@ struct NVGparams {
int (*renderDeleteTexture)(void* uptr, int image);
int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data);
int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h);
void (*renderViewport)(void* uptr, int width, int height);
void (*renderViewport)(void* uptr, int width, int height, float devicePixelRatio);
void (*renderCancel)(void* uptr);
void (*renderFlush)(void* uptr);
void (*renderFill)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths);
@ -598,12 +600,6 @@ struct NVGparams {
};
typedef struct NVGparams NVGparams;
namespace bx { struct AllocatorI; }
NVGcontext* nvgCreate(int edgeaa, unsigned char _viewId, bx::AllocatorI* _allocator = NULL);
void nvgViewId(struct NVGcontext* ctx, unsigned char _viewId);
void nvgDelete(struct NVGcontext* ctx);
// Constructor and destructor, called by the render back-end.
NVGcontext* nvgCreateInternal(NVGparams* params);
void nvgDeleteInternal(NVGcontext* ctx);

View File

@ -545,12 +545,13 @@ namespace
gl->th = handle;
}
static void nvgRenderViewport(void* _userPtr, int width, int height)
static void nvgRenderViewport(void* _userPtr, int width, int height, float devicePixelRatio)
{
struct GLNVGcontext* gl = (struct GLNVGcontext*)_userPtr;
gl->state = 0;
gl->view[0] = (float)width;
gl->view[1] = (float)height;
bgfx::setViewRect(gl->m_viewId, 0, 0, width, height);
bgfx::setViewRect(gl->m_viewId, 0, 0, width * devicePixelRatio, height * devicePixelRatio);
}
static void fan(uint32_t _start, uint32_t _count)
@ -714,33 +715,24 @@ namespace
int allocated = gl->tvb.size/gl->tvb.stride;
if (allocated < gl->nverts) {
if (allocated < gl->nverts)
{
gl->nverts = allocated;
BX_WARN(true, "Vertex number truncated due to transient vertex buffer overflow");
}
memcpy(gl->tvb.data, gl->verts, gl->nverts * sizeof(struct NVGvertex) );
gl->state = 0
if (0 == gl->state)
{
gl->state = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA);
}
gl->state |= 0
| BGFX_STATE_RGB_WRITE
| BGFX_STATE_ALPHA_WRITE
;
// if (alphaBlend == NVG_PREMULTIPLIED_ALPHA)
// {
// gl->state |= BGFX_STATE_BLEND_FUNC_SEPARATE(
// BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA
// , BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_ALPHA
// );
// }
// else
{
gl->state |= BGFX_STATE_BLEND_FUNC(
BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA
);
}
bgfx::setUniform(gl->u_viewSize, gl->view);
for (uint32_t ii = 0, num = gl->ncalls; ii < num; ++ii)
@ -1088,6 +1080,29 @@ error:
return NULL;
}
NVGcontext* nvgCreate(int edgeaa, unsigned char _viewId) {
return nvgCreate(edgeaa, _viewId, NULL);
}
void nvgDelete(struct NVGcontext* ctx)
{
nvgDeleteInternal(ctx);
}
void nvgState(struct NVGcontext* ctx, uint64_t state)
{
struct NVGparams* params = nvgInternalParams(ctx);
struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
gl->state = state;
}
uint8_t nvgViewId(struct NVGcontext* ctx)
{
struct NVGparams* params = nvgInternalParams(ctx);
struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
return gl->m_viewId;
}
void nvgViewId(struct NVGcontext* ctx, unsigned char _viewId)
{
struct NVGparams* params = nvgInternalParams(ctx);
@ -1095,7 +1110,55 @@ void nvgViewId(struct NVGcontext* ctx, unsigned char _viewId)
gl->m_viewId = uint8_t(_viewId);
}
void nvgDelete(struct NVGcontext* ctx)
bgfx::TextureHandle nvglImageHandle(NVGcontext* ctx, int image)
{
nvgDeleteInternal(ctx);
GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(ctx)->userPtr;
GLNVGtexture* tex = glnvg__findTexture(gl, image);
return tex->id;
}
NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int width,
int height, int imageFlags) {
NVGLUframebuffer* framebuffer = new NVGLUframebuffer;
framebuffer->ctx = ctx;
framebuffer->image = nvgCreateImageRGBA(ctx, width, height,
imageFlags, NULL);
bgfx::TextureHandle texture = nvglImageHandle(ctx, framebuffer->image);
if (!bgfx::isValid(texture)) {
nvgluDeleteFramebuffer(framebuffer);
return NULL;
}
framebuffer->handle = bgfx::createFrameBuffer(1, &texture, false);
if (!bgfx::isValid(framebuffer->handle))
{
nvgluDeleteFramebuffer(framebuffer);
return NULL;
}
static uint8_t s_ViewId = 1; // may have a better way to assign new view id
framebuffer->viewId = s_ViewId++;
bgfx::setViewFrameBuffer(framebuffer->viewId, framebuffer->handle);
bgfx::setViewSeq(framebuffer->viewId, true);
return framebuffer;
}
void nvgluBindFramebuffer(NVGLUframebuffer* framebuffer) {
static NVGcontext* s_prevCtx = NULL;
static uint8_t s_prevViewId;
if (framebuffer != NULL) {
s_prevCtx = framebuffer->ctx;
s_prevViewId = nvgViewId(framebuffer->ctx);
nvgViewId(framebuffer->ctx, framebuffer->viewId);
} else if (s_prevCtx != NULL) {
nvgViewId(s_prevCtx, s_prevViewId);
}
}
void nvgluDeleteFramebuffer(NVGLUframebuffer* framebuffer) {
if (framebuffer == NULL)
return;
if (framebuffer->image >= 0)
nvgDeleteImage(framebuffer->ctx, framebuffer->image);
if (bgfx::isValid(framebuffer->handle))
bgfx::destroyFrameBuffer(framebuffer->handle);
delete framebuffer;
}

View File

@ -0,0 +1,52 @@
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#ifndef NANOVG_BGFX_H_HEADER_GUARD
#define NANOVG_BGFX_H_HEADER_GUARD
#include "bgfx/bgfx.h"
namespace bx { struct AllocatorI; }
struct NVGcontext;
struct NVGLUframebuffer {
NVGcontext* ctx;
bgfx::FrameBufferHandle handle;
int image;
uint8_t viewId;
};
typedef struct NVGLUframebuffer NVGLUframebuffer;
NVGcontext* nvgCreate(int edgeaa, unsigned char _viewId, bx::AllocatorI* _allocator);
NVGcontext* nvgCreate(int edgeaa, unsigned char _viewId);
void nvgDelete(struct NVGcontext* ctx);
void nvgState(struct NVGcontext* ctx, uint64_t state);
uint8_t nvgViewId(struct NVGcontext* ctx);
void nvgViewId(struct NVGcontext* ctx, unsigned char _viewId);
// Helper functions to create bgfx framebuffer to render to.
// Example:
// float scale = 2;
// NVGLUframebuffer* fb = nvgluCreateFramebuffer(ctx, 100 * scale, 100 * scale, 0);
// nvgluBindFramebuffer(fb);
// nvgBeginFrame(ctx, 100, 100, scale);
// // renders anything offscreen
// nvgEndFrame(ctx);
// nvgluBindFramebuffer(NULL);
//
// // Pastes the framebuffer rendering.
// nvgBeginFrame(ctx, 1024, 768, scale);
// NVGpaint paint = nvgImagePattern(ctx, 0, 0, 100, 100, 0, fb->image, 1);
// nvgBeginPath(ctx);
// nvgRect(ctx, 0, 0, 100, 100);
// nvgFillPaint(ctx, paint);
// nvgFill(ctx);
// nvgEndFrame(ctx);
NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int width, int height, int imageFlags);
void nvgluBindFramebuffer(NVGLUframebuffer* framebuffer);
void nvgluDeleteFramebuffer(NVGLUframebuffer* framebuffer);
#endif // NANOVG_BGFX_H_HEADER_GUARD

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More