mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
Update BGFX and BX (nw)
This commit is contained in:
parent
1f352c6af8
commit
6412c5e076
@ -1,6 +1,14 @@
|
||||
GLSL optimizer Change Log
|
||||
=========================
|
||||
|
||||
2016 03
|
||||
-------
|
||||
|
||||
Fixed:
|
||||
|
||||
* Fixed translation performance regression in loop analysis (regressed in 2015 06 fixes).
|
||||
|
||||
|
||||
2015 08
|
||||
-------
|
||||
|
||||
@ -35,6 +43,7 @@ Fixes:
|
||||
-------
|
||||
|
||||
Goodies:
|
||||
|
||||
* GLES2: support EXT_draw_instanced / gl_InstanceIDEXT.
|
||||
* Support gl_VertexID in GLSL < 1.30 when EXT_gpu_shader4 is used.
|
||||
|
||||
|
@ -440,8 +440,12 @@ static bool propagate_precision(exec_list* list, bool assign_high_to_undefined)
|
||||
static void do_optimization_passes(exec_list* ir, bool linked, _mesa_glsl_parse_state* state, void* mem_ctx)
|
||||
{
|
||||
bool progress;
|
||||
// FIXME: Shouldn't need to bound the number of passes
|
||||
int passes = 0,
|
||||
kMaximumPasses = 1000;
|
||||
do {
|
||||
progress = false;
|
||||
++passes;
|
||||
bool progress2;
|
||||
debug_print_ir ("Initial", ir, state, mem_ctx);
|
||||
if (linked) {
|
||||
@ -497,7 +501,7 @@ static void do_optimization_passes(exec_list* ir, bool linked, _mesa_glsl_parse_
|
||||
}
|
||||
delete ls;
|
||||
}
|
||||
} while (progress);
|
||||
} while (progress && passes < kMaximumPasses);
|
||||
|
||||
if (!state->metal_target)
|
||||
{
|
||||
|
@ -1020,17 +1020,7 @@ void ir_print_metal_visitor::visit(ir_expression *ir)
|
||||
const bool halfCast = (arg_prec == glsl_precision_medium || arg_prec == glsl_precision_low);
|
||||
buffer.asprintf_append (halfCast ? "((half)1.0/(" : "(1.0/(");
|
||||
} else {
|
||||
switch(ir->operation) {
|
||||
case ir_unop_dFdy:
|
||||
case ir_unop_dFdy_coarse:
|
||||
case ir_unop_dFdy_fine:
|
||||
buffer.asprintf_append ("%s(-", operator_glsl_strs[ir->operation]);
|
||||
break;
|
||||
|
||||
default:
|
||||
buffer.asprintf_append ("%s(", operator_glsl_strs[ir->operation]);
|
||||
break;
|
||||
}
|
||||
buffer.asprintf_append ("%s(", operator_glsl_strs[ir->operation]);
|
||||
}
|
||||
if (ir->operands[0])
|
||||
ir->operands[0]->accept(this);
|
||||
|
@ -163,8 +163,10 @@ exec_node_get_prev(struct exec_node *n)
|
||||
static inline void
|
||||
exec_node_remove(struct exec_node *n)
|
||||
{
|
||||
n->next->prev = n->prev;
|
||||
n->prev->next = n->next;
|
||||
if (n->next)
|
||||
n->next->prev = n->prev;
|
||||
if (n->prev)
|
||||
n->prev->next = n->next;
|
||||
n->next = NULL;
|
||||
n->prev = NULL;
|
||||
}
|
||||
|
@ -25,11 +25,10 @@
|
||||
#include "loop_analysis.h"
|
||||
#include "ir_hierarchical_visitor.h"
|
||||
#include "ir_variable_refcount.h"
|
||||
#include "util/hash_table.h"
|
||||
|
||||
static bool is_loop_terminator(ir_if *ir);
|
||||
|
||||
static bool used_outside_loops(exec_node *head, ir_variable *var, bool first_assignment);
|
||||
|
||||
static bool all_expression_operands_are_loop_constant(ir_rvalue *,
|
||||
hash_table *);
|
||||
|
||||
@ -84,6 +83,8 @@ loop_state::loop_state()
|
||||
hash_table_pointer_compare);
|
||||
this->ht_non_inductors = hash_table_ctor(0, hash_table_pointer_hash,
|
||||
hash_table_pointer_compare);
|
||||
this->ht_variables = hash_table_ctor(0, hash_table_pointer_hash,
|
||||
hash_table_pointer_compare);
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->loop_found = false;
|
||||
}
|
||||
@ -94,6 +95,7 @@ loop_state::~loop_state()
|
||||
hash_table_dtor(this->ht);
|
||||
hash_table_dtor(this->ht_inductors);
|
||||
hash_table_dtor(this->ht_non_inductors);
|
||||
hash_table_dtor(this->ht_variables);
|
||||
ralloc_free(this->mem_ctx);
|
||||
}
|
||||
|
||||
@ -122,10 +124,36 @@ loop_state::get_for_inductor(const ir_variable *ir)
|
||||
return (loop_variable_state *) hash_table_find(this->ht_inductors, ir);
|
||||
}
|
||||
|
||||
static void *unreferenced_variable = (void *)1;
|
||||
static void *assigned_variable = (void *)2;
|
||||
|
||||
void
|
||||
loop_state::insert_non_inductor(ir_variable *var)
|
||||
loop_state::insert_variable(ir_variable *var)
|
||||
{
|
||||
// key doesn't matter, just needs to be non-NULL
|
||||
// data starts as 1. If an assignment is seen, it's replaced with 2.
|
||||
// this way we can mark a variable as a non-inductor if it's referenced
|
||||
// other than the first assignment
|
||||
hash_table_insert(this->ht_variables, unreferenced_variable, var);
|
||||
}
|
||||
|
||||
void
|
||||
loop_state::reference_variable(ir_variable *var, bool assignment)
|
||||
{
|
||||
void *ref = hash_table_find(this->ht_variables, var);
|
||||
|
||||
// variable declaration was not seen or already discarded, just ignore
|
||||
if (ref == NULL)
|
||||
return;
|
||||
|
||||
if (ref == unreferenced_variable && assignment)
|
||||
{
|
||||
hash_table_replace(this->ht_variables, assigned_variable, var);
|
||||
return;
|
||||
}
|
||||
|
||||
// variable is referenced and not just in an initial assignment,
|
||||
// so it cannot be an inductor
|
||||
hash_table_remove(this->ht_variables, var);
|
||||
hash_table_insert(this->ht_non_inductors, this, var);
|
||||
}
|
||||
|
||||
@ -266,10 +294,14 @@ public:
|
||||
virtual ir_visitor_status visit_enter(ir_if *);
|
||||
virtual ir_visitor_status visit_leave(ir_if *);
|
||||
|
||||
void visit_general(ir_instruction *);
|
||||
|
||||
loop_state *loops;
|
||||
|
||||
int if_statement_depth;
|
||||
|
||||
bool first_pass;
|
||||
|
||||
ir_assignment *current_assignment;
|
||||
|
||||
exec_list state;
|
||||
@ -277,10 +309,17 @@ public:
|
||||
|
||||
} /* anonymous namespace */
|
||||
|
||||
void loop_enter_callback(class ir_instruction *ir, void *data)
|
||||
{
|
||||
((loop_analysis *)data)->visit_general(ir);
|
||||
}
|
||||
|
||||
loop_analysis::loop_analysis(loop_state *loops)
|
||||
: loops(loops), if_statement_depth(0), current_assignment(NULL)
|
||||
: loops(loops), if_statement_depth(0), current_assignment(NULL), first_pass(false)
|
||||
{
|
||||
/* empty */
|
||||
data_enter = this;
|
||||
callback_enter = &loop_enter_callback;
|
||||
}
|
||||
|
||||
|
||||
@ -308,16 +347,11 @@ loop_analysis::visit(ir_variable *var)
|
||||
if (!this->state.is_empty())
|
||||
return visit_continue;
|
||||
|
||||
// Check if this variable is used outside a loop anywhere. If it is, it can't be a
|
||||
// variable that's private to the loop, so can't be an inductor.
|
||||
// This doesn't reject all possible non-inductors, notably anything declared in an
|
||||
// outer loop that isn't an inductor in an inner loop, but it can eliminate some
|
||||
// problem cases
|
||||
if (used_outside_loops(var->next, var, false))
|
||||
{
|
||||
// add to list of "non inductors"
|
||||
loops->insert_non_inductor(var);
|
||||
}
|
||||
// In the first pass over the instructions we look at variables declared and
|
||||
// examine their references to determine if they can be an inductor or not
|
||||
// for the second pass
|
||||
if (this->first_pass)
|
||||
loops->insert_variable(var);
|
||||
|
||||
return visit_continue;
|
||||
}
|
||||
@ -339,10 +373,15 @@ loop_analysis::visit_enter(ir_call *)
|
||||
ir_visitor_status
|
||||
loop_analysis::visit(ir_dereference_variable *ir)
|
||||
{
|
||||
/* If we're not somewhere inside a loop, there's nothing to do.
|
||||
/* If we're not somewhere inside a loop, just check for
|
||||
* non-inductors
|
||||
*/
|
||||
if (this->state.is_empty())
|
||||
if (this->state.is_empty() || this->first_pass)
|
||||
{
|
||||
if (this->state.is_empty() && this->first_pass)
|
||||
loops->reference_variable(ir->variable_referenced(), this->in_assignee);
|
||||
return visit_continue;
|
||||
}
|
||||
|
||||
bool nested = false;
|
||||
|
||||
@ -382,8 +421,11 @@ loop_analysis::visit_leave(ir_loop *ir)
|
||||
* We could perform some conservative analysis (prove there's no statically
|
||||
* possible assignment, etc.) but it isn't worth it for now; function
|
||||
* inlining will allow us to unroll loops anyway.
|
||||
*
|
||||
* We also skip doing any work in the first pass, where we are just identifying
|
||||
* variables that cannot be inductors.
|
||||
*/
|
||||
if (ls->contains_calls)
|
||||
if (ls->contains_calls || this->first_pass)
|
||||
return visit_continue;
|
||||
|
||||
foreach_in_list(ir_instruction, node, &ir->body_instructions) {
|
||||
@ -591,7 +633,7 @@ loop_analysis::visit_enter(ir_assignment *ir)
|
||||
/* If we're not somewhere inside a loop, there's nothing to do.
|
||||
*/
|
||||
if (this->state.is_empty())
|
||||
return visit_continue_with_parent;
|
||||
return visit_continue;
|
||||
|
||||
this->current_assignment = ir;
|
||||
|
||||
@ -601,10 +643,8 @@ loop_analysis::visit_enter(ir_assignment *ir)
|
||||
ir_visitor_status
|
||||
loop_analysis::visit_leave(ir_assignment *ir)
|
||||
{
|
||||
/* Since the visit_enter exits with visit_continue_with_parent for this
|
||||
* case, the loop state stack should never be empty here.
|
||||
*/
|
||||
assert(!this->state.is_empty());
|
||||
if (this->state.is_empty())
|
||||
return visit_continue;
|
||||
|
||||
assert(this->current_assignment == ir);
|
||||
this->current_assignment = NULL;
|
||||
@ -612,6 +652,24 @@ loop_analysis::visit_leave(ir_assignment *ir)
|
||||
return visit_continue;
|
||||
}
|
||||
|
||||
void
|
||||
loop_analysis::visit_general(ir_instruction *ir)
|
||||
{
|
||||
/* If we're inside a loop, we can't start marking things as non-inductors
|
||||
* Likewise in the second pass we've done all this work, so return early
|
||||
*/
|
||||
if (!this->state.is_empty() || !this->first_pass)
|
||||
return;
|
||||
|
||||
ir_variable_refcount_visitor refs;
|
||||
ir->accept (&refs);
|
||||
|
||||
struct hash_entry *referenced_var;
|
||||
hash_table_foreach (refs.ht, referenced_var) {
|
||||
ir_variable *var = (ir_variable *)referenced_var->key;
|
||||
loops->reference_variable(var, false);
|
||||
}
|
||||
}
|
||||
|
||||
class examine_rhs : public ir_hierarchical_visitor {
|
||||
public:
|
||||
@ -733,72 +791,23 @@ is_loop_terminator(ir_if *ir)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
used_outside_loops(exec_node *head, ir_variable *var, bool first_assignment)
|
||||
{
|
||||
ir_variable_refcount_visitor refs;
|
||||
for (exec_node* node = head;
|
||||
!node->is_tail_sentinel();
|
||||
node = node->next)
|
||||
{
|
||||
ir_instruction *ir = (ir_instruction *) node;
|
||||
if (ir->ir_type == ir_type_variable)
|
||||
continue;
|
||||
|
||||
// ignore the first assignment
|
||||
if (!first_assignment && ir->ir_type == ir_type_assignment)
|
||||
{
|
||||
ir_assignment *assign = ir->as_assignment();
|
||||
ir_variable *assignee = assign->lhs->whole_variable_referenced();
|
||||
|
||||
if(assignee == var)
|
||||
{
|
||||
first_assignment = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// we don't want to recurse into loops
|
||||
if (ir->ir_type == ir_type_loop)
|
||||
continue;
|
||||
|
||||
// recurse only for if statements, the other case we would need to recurse is
|
||||
// loops, but we are looking for uses outside of loops.
|
||||
if (ir->ir_type == ir_type_if)
|
||||
{
|
||||
ir_if *irif = ir->as_if();
|
||||
if (used_outside_loops(irif->then_instructions.head, var, first_assignment))
|
||||
return true;
|
||||
if (used_outside_loops(irif->else_instructions.head, var, first_assignment))
|
||||
return true;
|
||||
|
||||
// if we didn't find in each branch with our recursion, skip
|
||||
// otherwise the accept (&refs) below will recurse into loops
|
||||
// and may give a false positive.
|
||||
continue;
|
||||
}
|
||||
|
||||
// we know that we're not inside a loop as we haven't recursed inside,
|
||||
// and we started outside of a loop, so any references to this variable
|
||||
// mean it is used outside of any loops
|
||||
ir->accept (&refs);
|
||||
if (refs.find_variable_entry(var))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
loop_state *
|
||||
analyze_loop_variables(exec_list *instructions)
|
||||
{
|
||||
loop_state *loops = new loop_state;
|
||||
loop_analysis v(loops);
|
||||
|
||||
/* Do two passes over the instructions. The first pass builds a view
|
||||
* of the variables declared and whether or not they're used outside
|
||||
* of loops (if so, they cannot be inductors).
|
||||
*
|
||||
* In the second pass we apply this information to do the loop analysis
|
||||
* itself.
|
||||
*/
|
||||
v.first_pass = true;
|
||||
v.run(instructions);
|
||||
v.first_pass = false;
|
||||
v.run(instructions);
|
||||
|
||||
return v.loops;
|
||||
}
|
||||
|
@ -251,6 +251,8 @@ public:
|
||||
loop_variable_state* get_for_inductor (const ir_variable*);
|
||||
bool insert_inductor(loop_variable* loopvar, loop_variable_state* state, ir_loop* loop);
|
||||
void insert_non_inductor(ir_variable *var);
|
||||
void insert_variable(ir_variable *var);
|
||||
void reference_variable(ir_variable *var, bool assignment);
|
||||
|
||||
bool loop_found;
|
||||
|
||||
@ -267,6 +269,7 @@ private:
|
||||
*/
|
||||
hash_table *ht_inductors;
|
||||
hash_table *ht_non_inductors;
|
||||
hash_table *ht_variables;
|
||||
|
||||
|
||||
void *mem_ctx;
|
||||
|
@ -84,6 +84,8 @@ hash_table_ctor(unsigned num_buckets, hash_func_t hash,
|
||||
void
|
||||
hash_table_dtor(struct hash_table *ht)
|
||||
{
|
||||
if (!ht)
|
||||
return;
|
||||
hash_table_clear(ht);
|
||||
free(ht);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 gl_FragCoord [[position]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 varUV;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
constant float2 _xlat_mtl_const1[12] = {float2(-0.326212, -0.40581), float2(-0.840144, -0.07358), float2(-0.695914, 0.457137), float2(-0.203345, 0.620716), float2(0.96234, -0.194983), float2(0.473434, -0.480026), float2(0.519456, 0.767022), float2(0.185461, -0.893124), float2(0.507431, 0.064425), float2(0.89642, 0.412458), float2(-0.32194, -0.932615), float2(-0.791559, -0.59771)};
|
||||
struct xlatMtlShaderInput {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 gl_PointCoord [[point_coord]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half4 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_uv;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_uv;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
inline float4x4 _xlcast_float4x4(half4x4 v) { return float4x4(float4(v[0]), float4(v[1]), float4(v[2]), float4(v[3])); }
|
||||
inline float3x3 _xlcast_float3x3(half3x3 v) { return float3x3(float3(v[0]), float3(v[1]), float3(v[2])); }
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
inline float4x4 _xlinit_float4x4(float v) { return float4x4(float4(v), float4(v), float4(v), float4(v)); }
|
||||
inline float3x3 _xlinit_float3x3(float v) { return float3x3(float3(v), float3(v), float3(v)); }
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half4 xlv_COLOR0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half3 normal;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half3 inNormal;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 varUV;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 uv;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half3 uv1;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 uvHi;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#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 xlatMtlShaderInput {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float3 uv;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#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 xlatMtlShaderInput {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half3 uv;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#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 xlatMtlShaderInput {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _uv0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
half2 xlv_TEXCOORD0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
constant float3 _xlat_mtl_const1[8] = {float3(0.0130572, 0.587232, -0.119337), float3(0.323078, 0.0220727, -0.418873), float3(-0.310725, -0.191367, 0.0561369), float3(-0.479646, 0.0939877, -0.580265), float3(0.139999, -0.33577, 0.559679), float3(-0.248458, 0.255532, 0.348944), float3(0.18719, -0.702764, -0.231748), float3(0.884915, 0.284208, 0.368524)};
|
||||
struct xlatMtlShaderInput {
|
||||
|
@ -315,9 +315,9 @@ static bool CheckGLSL (bool vertex, bool gles, const std::string& testName, cons
|
||||
|
||||
static bool CheckMetal (bool vertex, bool gles, const std::string& testName, const char* prefix, const std::string& source)
|
||||
{
|
||||
#if !GOT_GFX
|
||||
#if !GOT_GFX || !defined(__APPLE__)
|
||||
return true; // just assume it's ok
|
||||
#endif
|
||||
#else
|
||||
|
||||
FILE* f = fopen ("metalTemp.metal", "wb");
|
||||
fwrite (source.c_str(), source.size(), 1, f);
|
||||
@ -333,6 +333,7 @@ static bool CheckMetal (bool vertex, bool gles, const std::string& testName, con
|
||||
#endif //
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _inVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _glesVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float3 _inPos [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _glesVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 dcl_Input0_POSITION0 [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 in_POSITION0 [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _glesVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _inVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
inline float4x4 _xlcast_float4x4(half4x4 v) { return float4x4(float4(v[0]), float4(v[1]), float4(v[2]), float4(v[3])); }
|
||||
inline float3x3 _xlcast_float3x3(half3x3 v) { return float3x3(float3(v[0]), float3(v[1]), float3(v[2])); }
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 attrVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _glesVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _inVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _glesVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _glesVertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _vertex [[attribute(0)]];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <metal_stdlib>
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 _inVertex [[attribute(0)]];
|
||||
|
98
3rdparty/bgfx/3rdparty/khronos/vulkan/vk_lunarg_debug_marker.h
vendored
Normal file
98
3rdparty/bgfx/3rdparty/khronos/vulkan/vk_lunarg_debug_marker.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
//
|
||||
// File: vk_lunarg_debug_marker.h
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2015-2016 The Khronos Group Inc.
|
||||
* Copyright (c) 2015-2016 Valve Corporation
|
||||
* Copyright (c) 2015-2016 LunarG, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and/or associated documentation files (the "Materials"), to
|
||||
* deal in the Materials without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Materials, and to permit persons to whom the Materials are
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice(s) and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
*
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
|
||||
* USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*
|
||||
* Authors:
|
||||
* Jon Ashburn <jon@lunarg.com>
|
||||
* Courtney Goeltzenleuchter <courtney@lunarg.com>
|
||||
*/
|
||||
|
||||
#ifndef __VK_DEBUG_MARKER_H__
|
||||
#define __VK_DEBUG_MARKER_H__
|
||||
|
||||
#include "vulkan.h"
|
||||
|
||||
#define VK_DEBUG_MARKER_EXTENSION_NUMBER 6
|
||||
#define VK_DEBUG_MARKER_EXTENSION_REVISION 1
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* DebugMarker Vulkan Extension API
|
||||
***************************************************************************************************
|
||||
*/
|
||||
|
||||
#define DEBUG_MARKER_EXTENSION_NAME "VK_LUNARG_DEBUG_MARKER"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Enumerations
|
||||
|
||||
#define VK_DEBUG_MARKER_ENUM_EXTEND(type, id) \
|
||||
((type)(VK_DEBUG_MARKER_EXTENSION_NUMBER * -1000 + (id)))
|
||||
|
||||
#define VK_OBJECT_INFO_TYPE_DBG_OBJECT_TAG \
|
||||
VK_DEBUG_MARKER_ENUM_EXTEND(VkDbgObjectInfoType, 0)
|
||||
#define VK_OBJECT_INFO_TYPE_DBG_OBJECT_NAME \
|
||||
VK_DEBUG_MARKER_ENUM_EXTEND(VkDbgObjectInfoType, 1)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// API functions
|
||||
|
||||
typedef void(VKAPI_PTR *PFN_vkCmdDbgMarkerBegin)(VkCommandBuffer commandBuffer,
|
||||
const char *pMarker);
|
||||
typedef void(VKAPI_PTR *PFN_vkCmdDbgMarkerEnd)(VkCommandBuffer commandBuffer);
|
||||
typedef VkResult(VKAPI_PTR *PFN_vkDbgSetObjectTag)(
|
||||
VkDevice device, VkDebugReportObjectTypeEXT objType, uint64_t object,
|
||||
size_t tagSize, const void *pTag);
|
||||
typedef VkResult(VKAPI_PTR *PFN_vkDbgSetObjectName)(
|
||||
VkDevice device, VkDebugReportObjectTypeEXT objType, uint64_t object,
|
||||
size_t nameSize, const char *pName);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
|
||||
// DebugMarker extension entrypoints
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
vkCmdDbgMarkerBegin(VkCommandBuffer commandBuffer, const char *pMarker);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdDbgMarkerEnd(VkCommandBuffer commandBuffer);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vkDbgSetObjectTag(VkDevice device, VkDebugReportObjectTypeEXT objType,
|
||||
uint64_t object, size_t tagSize, const void *pTag);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vkDbgSetObjectName(VkDevice device, VkDebugReportObjectTypeEXT objType,
|
||||
uint64_t object, size_t nameSize, const char *pName);
|
||||
|
||||
#endif // VK_NO_PROTOTYPES
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __VK_DEBUG_MARKER_H__
|
127
3rdparty/bgfx/3rdparty/khronos/vulkan/vk_platform.h
vendored
Normal file
127
3rdparty/bgfx/3rdparty/khronos/vulkan/vk_platform.h
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
//
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright (c) 2014-2015 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __VK_PLATFORM_H__
|
||||
#define __VK_PLATFORM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Platform-specific directives and type declarations
|
||||
***************************************************************************************************
|
||||
*/
|
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
*
|
||||
* Platforms should define these so that Vulkan clients call Vulkan commands
|
||||
* with the same calling conventions that the Vulkan implementation expects.
|
||||
*
|
||||
* VKAPI_ATTR - Placed before the return type in function declarations.
|
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
||||
* VKAPI_CALL - Placed after the return type in function declarations.
|
||||
* Useful for MSVC-style calling convention syntax.
|
||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
||||
*
|
||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
|
||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
// On Windows, Vulkan commands use the stdcall convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL __stdcall
|
||||
#define VKAPI_PTR VKAPI_CALL
|
||||
#elif defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
|
||||
// Android does not support Vulkan in native code using the "armeabi" ABI.
|
||||
#error "Vulkan requires the 'armeabi-v7a' or 'armeabi-v7a-hard' ABI on 32-bit ARM CPUs"
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH_7A__)
|
||||
// On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling
|
||||
// convention, even if the application's native code is compiled with the
|
||||
// armeabi-v7a calling convention.
|
||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR VKAPI_ATTR
|
||||
#else
|
||||
// On other platforms, use the default calling convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(VK_NO_STDINT_H)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif // !defined(VK_NO_STDINT_H)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
// Platform-specific headers required by platform window system extensions.
|
||||
// These are enabled prior to #including "vulkan.h". The same enable then
|
||||
// controls inclusion of the extension interfaces in vulkan.h.
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <android/native_window.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MIR_KHR
|
||||
#include <mir_toolkit/client_types.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#include <wayland-client.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
#endif // __VK_PLATFORM_H__
|
3775
3rdparty/bgfx/3rdparty/khronos/vulkan/vulkan.h
vendored
Normal file
3775
3rdparty/bgfx/3rdparty/khronos/vulkan/vulkan.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
3rdparty/bgfx/3rdparty/nvtt/nvcore/posh.h
vendored
6
3rdparty/bgfx/3rdparty/nvtt/nvcore/posh.h
vendored
@ -412,7 +412,9 @@ LLVM:
|
||||
# if !defined POSH_OS_XBOX
|
||||
# if defined _WIN64
|
||||
# define POSH_OS_WIN64 1
|
||||
# define POSH_OS_STRING "Win64"
|
||||
# if !defined POSH_OS_STRING
|
||||
# define POSH_OS_STRING "Win64"
|
||||
# endif // !defined POSH_OS_STRING
|
||||
# else
|
||||
# if !defined POSH_OS_STRING
|
||||
# define POSH_OS_STRING "Win32"
|
||||
@ -1026,5 +1028,3 @@ extern posh_i64_t POSH_ReadI64FromBig( const void *src );
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
42
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
42
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -595,7 +595,7 @@ static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y
|
||||
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCond cond);
|
||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond cond);
|
||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiSetCond cond);
|
||||
static ImGuiWindow* FindWindowByName(const char* name);
|
||||
ImGuiWindow* FindWindowByName(const char* name);
|
||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
|
||||
static inline bool IsWindowContentHoverable(ImGuiWindow* window);
|
||||
@ -2286,25 +2286,26 @@ static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>& out_sorted_windows,
|
||||
|
||||
static void AddDrawListToRenderList(ImVector<ImDrawList*>& out_render_list, ImDrawList* draw_list)
|
||||
{
|
||||
if (!draw_list->CmdBuffer.empty() && !draw_list->VtxBuffer.empty())
|
||||
if (draw_list->CmdBuffer.empty())
|
||||
return;
|
||||
|
||||
// Remove trailing command if unused
|
||||
ImDrawCmd& last_cmd = draw_list->CmdBuffer.back();
|
||||
if (last_cmd.ElemCount == 0 && last_cmd.UserCallback == NULL)
|
||||
{
|
||||
// Remove trailing command if unused
|
||||
ImDrawCmd& last_cmd = draw_list->CmdBuffer.back();
|
||||
if (last_cmd.ElemCount == 0 && last_cmd.UserCallback == NULL)
|
||||
draw_list->CmdBuffer.pop_back();
|
||||
|
||||
out_render_list.push_back(draw_list);
|
||||
|
||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = 2 bytes = 64K vertices)
|
||||
// If this assert triggers because you are drawing lots of stuff manually, A) workaround by calling BeginChild()/EndChild() to put your draw commands in multiple draw lists, B) #define ImDrawIdx to a 'unsigned int' in imconfig.h and render accordingly.
|
||||
const unsigned long long int max_vtx_idx = (unsigned long long int)1L << (sizeof(ImDrawIdx)*8);
|
||||
(void)max_vtx_idx;
|
||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); // Sanity check. Bug or mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||
IM_ASSERT((unsigned long long int)draw_list->_VtxCurrentIdx <= max_vtx_idx); // Too many vertices in same ImDrawList. See comment above.
|
||||
|
||||
GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size;
|
||||
GImGui->IO.MetricsRenderIndices += draw_list->IdxBuffer.Size;
|
||||
draw_list->CmdBuffer.pop_back();
|
||||
if (draw_list->CmdBuffer.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = 2 bytes = 64K vertices)
|
||||
// If this assert triggers because you are drawing lots of stuff manually, A) workaround by calling BeginChild()/EndChild() to put your draw commands in multiple draw lists, B) #define ImDrawIdx to a 'unsigned int' in imconfig.h and render accordingly.
|
||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); // Sanity check. Bug or mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||
IM_ASSERT((unsigned long long int)draw_list->_VtxCurrentIdx <= ((unsigned long long int)1L << (sizeof(ImDrawIdx)*8))); // Too many vertices in same ImDrawList. See comment above.
|
||||
|
||||
out_render_list.push_back(draw_list);
|
||||
GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size;
|
||||
GImGui->IO.MetricsRenderIndices += draw_list->IdxBuffer.Size;
|
||||
}
|
||||
|
||||
static void AddWindowToRenderList(ImVector<ImDrawList*>& out_render_list, ImGuiWindow* window)
|
||||
@ -3458,9 +3459,9 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size,
|
||||
return pos;
|
||||
}
|
||||
|
||||
static ImGuiWindow* FindWindowByName(const char* name)
|
||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
{
|
||||
// FIXME-OPT: Store sorted hashes -> pointers.
|
||||
// FIXME-OPT: Store sorted hashes -> pointers so we can do a bissection in a contiguous block
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiID id = ImHash(name, 0);
|
||||
for (int i = 0; i < g.Windows.Size; i++)
|
||||
@ -7209,6 +7210,7 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f
|
||||
}
|
||||
|
||||
// Edit a string of text
|
||||
// NB: when active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while active has no effect.
|
||||
// FIXME: Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls. Ideally we should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188
|
||||
bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data)
|
||||
{
|
||||
|
4
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
4
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
@ -146,8 +146,8 @@ namespace ImGui
|
||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing
|
||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set current window collapsed state
|
||||
IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most
|
||||
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position - call within Begin()/End(). may incur tearing
|
||||
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. may incur tearing
|
||||
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position.
|
||||
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
|
||||
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); // set named window collapsed state
|
||||
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus.
|
||||
|
||||
|
@ -675,6 +675,7 @@ namespace ImGui
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; }
|
||||
inline ImGuiWindow* GetCurrentWindow() { ImGuiState& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
|
||||
IMGUI_API ImGuiWindow* GetParentWindow();
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
|
||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||
|
17
3rdparty/bgfx/3rdparty/renderdoc/renderdoc_app.h
vendored
17
3rdparty/bgfx/3rdparty/renderdoc/renderdoc_app.h
vendored
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Baldur Karlsson
|
||||
* Copyright (c) 2015-2016 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -445,10 +445,17 @@ typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePoin
|
||||
// instead of 1.0.0. You can check this with the GetAPIVersion entry point
|
||||
typedef enum
|
||||
{
|
||||
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 000 000
|
||||
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
|
||||
} RENDERDOC_Version;
|
||||
|
||||
// eRENDERDOC_API_Version_1_0_0
|
||||
// API version changelog:
|
||||
//
|
||||
// 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.
|
||||
|
||||
// eRENDERDOC_API_Version_1_0_1
|
||||
typedef struct
|
||||
{
|
||||
pRENDERDOC_GetAPIVersion GetAPIVersion;
|
||||
@ -484,7 +491,9 @@ typedef struct
|
||||
pRENDERDOC_StartFrameCapture StartFrameCapture;
|
||||
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
|
||||
pRENDERDOC_EndFrameCapture EndFrameCapture;
|
||||
} RENDERDOC_API_1_0_0;
|
||||
} RENDERDOC_API_1_0_1;
|
||||
|
||||
typedef RENDERDOC_API_1_0_1 RENDERDOC_API_1_0_0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// RenderDoc API entry point
|
||||
|
3
3rdparty/bgfx/3rdparty/stb/stb_image.c
vendored
3
3rdparty/bgfx/3rdparty/stb/stb_image.c
vendored
@ -1,6 +1,9 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
# ifndef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
# endif // __clang__
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(disable:4312) // warning C4312: 'type cast': conversion from '' to '' of greater size
|
||||
# pragma warning(disable:4456) // warning C4456: declaration of 'k' hides previous local declaration
|
||||
|
26
3rdparty/bgfx/README.md
vendored
26
3rdparty/bgfx/README.md
vendored
@ -55,14 +55,24 @@ Languages:
|
||||
* [Go language API bindings](https://github.com/james4k/go-bgfx)
|
||||
* [Java language API bindings](https://github.com/enleeten/twilight-bgfx)
|
||||
* [Haskell language API bindings](https://github.com/haskell-game/bgfx)
|
||||
* [Python language API bindings](https://github.com/jnadro/pybgfx#pybgf)
|
||||
* [Rust language API bindings](https://github.com/rhoot/bgfx-rs)
|
||||
|
||||
Build
|
||||
-----
|
||||
[Building](https://bkaradzic.github.io/bgfx/build.html)
|
||||
----------------------------------------------------
|
||||
|
||||
- AppVeyor https://ci.appveyor.com/project/bkaradzic/bgfx
|
||||
- TravisCI https://travis-ci.org/bkaradzic/bgfx
|
||||
|
||||
[Examples](https://bkaradzic.github.io/bgfx/examples.html)
|
||||
----------------------------------------------------------
|
||||
|
||||
[API Reference](https://bkaradzic.github.io/bgfx/bgfx.html)
|
||||
-----------------------------------------------------------
|
||||
|
||||
[Tools](https://bkaradzic.github.io/bgfx/tools.html)
|
||||
----------------------------------------------------
|
||||
|
||||
Who is using it?
|
||||
----------------
|
||||
|
||||
@ -118,18 +128,6 @@ http://makingartstudios.itch.io/dls - DLS the digital logic simulator game.
|
||||
|
||||
https://github.com/mamedev/mame MAME - Multiple Arcade Machine Emulator
|
||||
|
||||
[Building](https://bkaradzic.github.io/bgfx/build.html)
|
||||
-------------------------------------------------------
|
||||
|
||||
[Examples](https://bkaradzic.github.io/bgfx/examples.html)
|
||||
----------------------------------------------------------
|
||||
|
||||
[API Reference](https://bkaradzic.github.io/bgfx/bgfx.html)
|
||||
-----------------------------------------------------------
|
||||
|
||||
[Tools](https://bkaradzic.github.io/bgfx/tools.html)
|
||||
----------------------------------------------------
|
||||
|
||||
[License (BSD 2-clause)](https://bkaradzic.github.io/bgfx/license.html)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
|
4
3rdparty/bgfx/examples/01-cubes/cubes.cpp
vendored
4
3rdparty/bgfx/examples/01-cubes/cubes.cpp
vendored
@ -55,7 +55,7 @@ static const uint16_t s_cubeIndices[36] =
|
||||
6, 3, 7,
|
||||
};
|
||||
|
||||
class Cubes : public entry::AppI
|
||||
class ExampleCubes : public entry::AppI
|
||||
{
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
@ -218,4 +218,4 @@ class Cubes : public entry::AppI
|
||||
int64_t m_timeOffset;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(Cubes);
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleCubes);
|
||||
|
3
3rdparty/bgfx/examples/01-cubes/makefile
vendored
3
3rdparty/bgfx/examples/01-cubes/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
2
3rdparty/bgfx/examples/02-metaballs/makefile
vendored
2
3rdparty/bgfx/examples/02-metaballs/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
|
@ -462,16 +462,16 @@ uint32_t triangulate(uint8_t* _result, uint32_t _stride, const float* __restrict
|
||||
|
||||
#define DIMS 32
|
||||
|
||||
class Metaballs : public entry::AppI
|
||||
class ExampleMetaballs : public entry::AppI
|
||||
{
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
m_width = 1280;
|
||||
m_width = 1280;
|
||||
m_height = 720;
|
||||
m_debug = BGFX_DEBUG_TEXT;
|
||||
m_reset = BGFX_RESET_VSYNC;
|
||||
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);
|
||||
@ -778,7 +778,6 @@ class Metaballs : public entry::AppI
|
||||
|
||||
Grid* m_grid;
|
||||
int64_t m_timeOffset;
|
||||
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(Metaballs);
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleMetaballs);
|
||||
|
3
3rdparty/bgfx/examples/03-raymarch/makefile
vendored
3
3rdparty/bgfx/examples/03-raymarch/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
267
3rdparty/bgfx/examples/03-raymarch/raymarch.cpp
vendored
267
3rdparty/bgfx/examples/03-raymarch/raymarch.cpp
vendored
@ -102,138 +102,163 @@ void renderScreenSpaceQuad(uint32_t _view, bgfx::ProgramHandle _program, float _
|
||||
}
|
||||
}
|
||||
|
||||
int _main_(int _argc, char** _argv)
|
||||
class ExampleRaymarch : public entry::AppI
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
uint32_t width = 1280;
|
||||
uint32_t height = 720;
|
||||
uint32_t debug = BGFX_DEBUG_TEXT;
|
||||
uint32_t reset = BGFX_RESET_VSYNC;
|
||||
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(width, height, reset);
|
||||
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(debug);
|
||||
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
// Setup root path for binary shaders. Shader binaries are different
|
||||
// for each renderer.
|
||||
switch (bgfx::getRendererType() )
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
default:
|
||||
break;
|
||||
Args args(_argc, _argv);
|
||||
|
||||
m_width = 1280;
|
||||
m_height = 720;
|
||||
m_debug = BGFX_DEBUG_TEXT;
|
||||
m_reset = BGFX_RESET_VSYNC;
|
||||
|
||||
case bgfx::RendererType::OpenGL:
|
||||
case bgfx::RendererType::OpenGLES:
|
||||
s_oglNdc = true;
|
||||
break;
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(m_width, m_height, m_reset);
|
||||
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(m_debug);
|
||||
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
// Setup root path for binary shaders. Shader binaries are different
|
||||
// for each renderer.
|
||||
switch (bgfx::getRendererType() )
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case bgfx::RendererType::OpenGL:
|
||||
case bgfx::RendererType::OpenGLES:
|
||||
s_oglNdc = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Create vertex stream declaration.
|
||||
PosColorTexCoord0Vertex::init();
|
||||
|
||||
u_mtx = bgfx::createUniform("u_mtx", bgfx::UniformType::Mat4);
|
||||
u_lightDirTime = bgfx::createUniform("u_lightDirTime", bgfx::UniformType::Vec4);
|
||||
|
||||
// Create program from shaders.
|
||||
m_program = loadProgram("vs_raymarching", "fs_raymarching");
|
||||
|
||||
m_timeOffset = bx::getHPCounter();
|
||||
}
|
||||
|
||||
// Create vertex stream declaration.
|
||||
PosColorTexCoord0Vertex::init();
|
||||
|
||||
bgfx::UniformHandle u_mtx = bgfx::createUniform("u_mtx", bgfx::UniformType::Mat4);
|
||||
bgfx::UniformHandle u_lightDirTime = bgfx::createUniform("u_lightDirTime", bgfx::UniformType::Vec4);
|
||||
|
||||
// Create program from shaders.
|
||||
bgfx::ProgramHandle raymarching = loadProgram("vs_raymarching", "fs_raymarching");
|
||||
|
||||
int64_t timeOffset = bx::getHPCounter();
|
||||
|
||||
while (!entry::processEvents(width, height, debug, reset) )
|
||||
int shutdown() BX_OVERRIDE
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
// Cleanup.
|
||||
bgfx::destroyProgram(m_program);
|
||||
|
||||
// Set view 1 default viewport.
|
||||
bgfx::setViewRect(1, 0, 0, width, height);
|
||||
bgfx::destroyUniform(u_mtx);
|
||||
bgfx::destroyUniform(u_lightDirTime);
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to viewZ 0.
|
||||
bgfx::touch(0);
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
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;
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/03-raymarch");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Updating shader uniforms.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -15.0f };
|
||||
|
||||
float view[16];
|
||||
float proj[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 1.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
float ortho[16];
|
||||
bx::mtxOrtho(ortho, 0.0f, 1280.0f, 720.0f, 0.0f, 0.0f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(1, NULL, ortho);
|
||||
|
||||
float time = (float)( (bx::getHPCounter()-timeOffset)/double(bx::getHPFrequency() ) );
|
||||
|
||||
float vp[16];
|
||||
bx::mtxMul(vp, view, proj);
|
||||
|
||||
float mtx[16];
|
||||
bx::mtxRotateXY(mtx
|
||||
, time
|
||||
, time*0.37f
|
||||
);
|
||||
|
||||
float mtxInv[16];
|
||||
bx::mtxInverse(mtxInv, mtx);
|
||||
float lightDirModel[4] = { -0.4f, -0.5f, -1.0f, 0.0f };
|
||||
float lightDirModelN[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
bx::vec3Norm(lightDirModelN, lightDirModel);
|
||||
float lightDirTime[4];
|
||||
bx::vec4MulMtx(lightDirTime, lightDirModelN, mtxInv);
|
||||
lightDirTime[3] = time;
|
||||
bgfx::setUniform(u_lightDirTime, lightDirTime);
|
||||
|
||||
float mvp[16];
|
||||
bx::mtxMul(mvp, mtx, vp);
|
||||
|
||||
float invMvp[16];
|
||||
bx::mtxInverse(invMvp, mvp);
|
||||
bgfx::setUniform(u_mtx, invMvp);
|
||||
|
||||
renderScreenSpaceQuad(1, raymarching, 0.0f, 0.0f, 1280.0f, 720.0f);
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
bgfx::destroyProgram(raymarching);
|
||||
bool update() BX_OVERRIDE
|
||||
{
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
bgfx::destroyUniform(u_mtx);
|
||||
bgfx::destroyUniform(u_lightDirTime);
|
||||
// Set view 1 default viewport.
|
||||
bgfx::setViewRect(1, 0, 0, m_width, m_height);
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to viewZ 0.
|
||||
bgfx::touch(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/03-raymarch");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Updating shader uniforms.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -15.0f };
|
||||
|
||||
float view[16];
|
||||
float proj[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 1.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
float ortho[16];
|
||||
bx::mtxOrtho(ortho, 0.0f, 1280.0f, 720.0f, 0.0f, 0.0f, 100.0f);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(1, NULL, ortho);
|
||||
|
||||
float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) );
|
||||
|
||||
float vp[16];
|
||||
bx::mtxMul(vp, view, proj);
|
||||
|
||||
float mtx[16];
|
||||
bx::mtxRotateXY(mtx
|
||||
, time
|
||||
, time*0.37f
|
||||
);
|
||||
|
||||
float mtxInv[16];
|
||||
bx::mtxInverse(mtxInv, mtx);
|
||||
float lightDirModel[4] = { -0.4f, -0.5f, -1.0f, 0.0f };
|
||||
float lightDirModelN[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
bx::vec3Norm(lightDirModelN, lightDirModel);
|
||||
float lightDirTime[4];
|
||||
bx::vec4MulMtx(lightDirTime, lightDirModelN, mtxInv);
|
||||
lightDirTime[3] = time;
|
||||
bgfx::setUniform(u_lightDirTime, lightDirTime);
|
||||
|
||||
float mvp[16];
|
||||
bx::mtxMul(mvp, mtx, vp);
|
||||
|
||||
float invMvp[16];
|
||||
bx::mtxInverse(invMvp, mvp);
|
||||
bgfx::setUniform(u_mtx, invMvp);
|
||||
|
||||
renderScreenSpaceQuad(1, m_program, 0.0f, 0.0f, 1280.0f, 720.0f);
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
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;
|
||||
bgfx::UniformHandle u_mtx;
|
||||
bgfx::UniformHandle u_lightDirTime;
|
||||
bgfx::ProgramHandle m_program;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleRaymarch);
|
||||
|
3
3rdparty/bgfx/examples/04-mesh/makefile
vendored
3
3rdparty/bgfx/examples/04-mesh/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
225
3rdparty/bgfx/examples/04-mesh/mesh.cpp
vendored
225
3rdparty/bgfx/examples/04-mesh/mesh.cpp
vendored
@ -6,118 +6,143 @@
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
int _main_(int _argc, char** _argv)
|
||||
class ExampleMesh : public entry::AppI
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
uint32_t width = 1280;
|
||||
uint32_t height = 720;
|
||||
uint32_t debug = BGFX_DEBUG_TEXT;
|
||||
uint32_t reset = BGFX_RESET_VSYNC;
|
||||
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(width, height, reset);
|
||||
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(debug);
|
||||
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
bgfx::UniformHandle u_time = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
|
||||
|
||||
// Create program from shaders.
|
||||
bgfx::ProgramHandle program = loadProgram("vs_mesh", "fs_mesh");
|
||||
|
||||
Mesh* mesh = meshLoad("meshes/bunny.bin");
|
||||
|
||||
int64_t timeOffset = bx::getHPCounter();
|
||||
|
||||
while (!entry::processEvents(width, height, debug, reset) )
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
Args args(_argc, _argv);
|
||||
|
||||
m_width = 1280;
|
||||
m_height = 720;
|
||||
m_debug = BGFX_DEBUG_TEXT;
|
||||
m_reset = BGFX_RESET_VSYNC;
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::touch(0);
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(m_width, m_height, m_reset);
|
||||
|
||||
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()-timeOffset)/double(bx::getHPFrequency() ) );
|
||||
bgfx::setUniform(u_time, &time);
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(m_debug);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/04-mesh");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Loading meshes.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
float at[3] = { 0.0f, 1.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 1.0f, -2.5f };
|
||||
u_time = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
const bgfx::HMD* hmd = bgfx::getHMD();
|
||||
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
|
||||
// Create program from shaders.
|
||||
m_program = loadProgram("vs_mesh", "fs_mesh");
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
m_mesh = meshLoad("meshes/bunny.bin");
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
//
|
||||
// Use HMD's width/height since HMD's internal frame buffer size
|
||||
// might be much larger than window size.
|
||||
bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
}
|
||||
|
||||
float mtx[16];
|
||||
bx::mtxRotateXY(mtx
|
||||
, 0.0f
|
||||
, time*0.37f
|
||||
);
|
||||
|
||||
meshSubmit(mesh, 0, program, mtx);
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
m_timeOffset = bx::getHPCounter();
|
||||
}
|
||||
|
||||
meshUnload(mesh);
|
||||
int shutdown() BX_OVERRIDE
|
||||
{
|
||||
meshUnload(m_mesh);
|
||||
|
||||
// Cleanup.
|
||||
bgfx::destroyProgram(program);
|
||||
// Cleanup.
|
||||
bgfx::destroyProgram(m_program);
|
||||
|
||||
bgfx::destroyUniform(u_time);
|
||||
bgfx::destroyUniform(u_time);
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool update() BX_OVERRIDE
|
||||
{
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::touch(0);
|
||||
|
||||
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() ) );
|
||||
bgfx::setUniform(u_time, &time);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/04-mesh");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Loading meshes.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
float at[3] = { 0.0f, 1.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 1.0f, -2.5f };
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
const bgfx::HMD* hmd = bgfx::getHMD();
|
||||
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
//
|
||||
// Use HMD's width/height since HMD's internal frame buffer size
|
||||
// might be much larger than window size.
|
||||
bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
}
|
||||
|
||||
float mtx[16];
|
||||
bx::mtxRotateXY(mtx
|
||||
, 0.0f
|
||||
, time*0.37f
|
||||
);
|
||||
|
||||
meshSubmit(m_mesh, 0, m_program, mtx);
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
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;
|
||||
Mesh* m_mesh;
|
||||
bgfx::ProgramHandle m_program;
|
||||
bgfx::UniformHandle u_time;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleMesh);
|
||||
|
305
3rdparty/bgfx/examples/05-instancing/instancing.cpp
vendored
305
3rdparty/bgfx/examples/05-instancing/instancing.cpp
vendored
@ -55,171 +55,196 @@ static const uint16_t s_cubeIndices[36] =
|
||||
6, 3, 7,
|
||||
};
|
||||
|
||||
int _main_(int _argc, char** _argv)
|
||||
class ExampleInstancing : public entry::AppI
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
uint32_t width = 1280;
|
||||
uint32_t height = 720;
|
||||
uint32_t debug = BGFX_DEBUG_TEXT;
|
||||
uint32_t reset = BGFX_RESET_VSYNC;
|
||||
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(width, height, reset);
|
||||
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(debug);
|
||||
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
// Get renderer capabilities info.
|
||||
const bgfx::Caps* caps = bgfx::getCaps();
|
||||
|
||||
// Create vertex stream declaration.
|
||||
PosColorVertex::init();
|
||||
|
||||
const bgfx::Memory* mem;
|
||||
|
||||
// Create static vertex buffer.
|
||||
mem = bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) );
|
||||
bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(mem, PosColorVertex::ms_decl);
|
||||
|
||||
// Create static index buffer.
|
||||
mem = bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) );
|
||||
bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(mem);
|
||||
|
||||
// Create program from shaders.
|
||||
bgfx::ProgramHandle program = loadProgram("vs_instancing", "fs_instancing");
|
||||
|
||||
int64_t timeOffset = bx::getHPCounter();
|
||||
|
||||
while (!entry::processEvents(width, height, debug, reset) )
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
Args args(_argc, _argv);
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::touch(0);
|
||||
m_width = 1280;
|
||||
m_height = 720;
|
||||
m_debug = BGFX_DEBUG_TEXT;
|
||||
m_reset = BGFX_RESET_VSYNC;
|
||||
|
||||
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)( (now - timeOffset)/double(bx::getHPFrequency() ) );
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(m_width, m_height, m_reset);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/05-instancing");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Geometry instancing.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(m_debug);
|
||||
|
||||
// Check if instancing is supported.
|
||||
if (0 == (BGFX_CAPS_INSTANCING & caps->supported) )
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
// Create vertex stream declaration.
|
||||
PosColorVertex::init();
|
||||
|
||||
// Create static vertex buffer.
|
||||
m_vbh = bgfx::createVertexBuffer(
|
||||
bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
|
||||
, PosColorVertex::ms_decl
|
||||
);
|
||||
|
||||
// Create static index buffer.
|
||||
m_ibh = bgfx::createIndexBuffer(
|
||||
bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) )
|
||||
);
|
||||
|
||||
// Create program from shaders.
|
||||
m_program = loadProgram("vs_instancing", "fs_instancing");
|
||||
|
||||
m_timeOffset = bx::getHPCounter();
|
||||
}
|
||||
|
||||
int shutdown() BX_OVERRIDE
|
||||
{
|
||||
// Cleanup.
|
||||
bgfx::destroyIndexBuffer(m_ibh);
|
||||
bgfx::destroyVertexBuffer(m_vbh);
|
||||
bgfx::destroyProgram(m_program);
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool update() BX_OVERRIDE
|
||||
{
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
|
||||
{
|
||||
// When instancing is not supported by GPU, implement alternative
|
||||
// code path that doesn't use instancing.
|
||||
bool blink = uint32_t(time*3.0f)&1;
|
||||
bgfx::dbgTextPrintf(0, 5, blink ? 0x1f : 0x01, " Instancing is not supported by GPU. ");
|
||||
}
|
||||
else
|
||||
{
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -35.0f };
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
const bgfx::HMD* hmd = bgfx::getHMD();
|
||||
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::touch(0);
|
||||
|
||||
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)( (now - m_timeOffset)/double(bx::getHPFrequency() ) );
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/05-instancing");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Geometry instancing.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
// Get renderer capabilities info.
|
||||
const bgfx::Caps* caps = bgfx::getCaps();
|
||||
|
||||
// Check if instancing is supported.
|
||||
if (0 == (BGFX_CAPS_INSTANCING & caps->supported) )
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
//
|
||||
// Use HMD's width/height since HMD's internal frame buffer size
|
||||
// might be much larger than window size.
|
||||
bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
|
||||
// When instancing is not supported by GPU, implement alternative
|
||||
// code path that doesn't use instancing.
|
||||
bool blink = uint32_t(time*3.0f)&1;
|
||||
bgfx::dbgTextPrintf(0, 5, blink ? 0x1f : 0x01, " Instancing is not supported by GPU. ");
|
||||
}
|
||||
else
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -35.0f };
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
}
|
||||
|
||||
const uint16_t instanceStride = 80;
|
||||
const bgfx::InstanceDataBuffer* idb = bgfx::allocInstanceDataBuffer(121, instanceStride);
|
||||
if (NULL != idb)
|
||||
{
|
||||
uint8_t* data = idb->data;
|
||||
|
||||
// Write instance data for 11x11 cubes.
|
||||
for (uint32_t yy = 0, numInstances = 0; yy < 11 && numInstances < idb->num; ++yy)
|
||||
// Set view and projection matrix for view 0.
|
||||
const bgfx::HMD* hmd = bgfx::getHMD();
|
||||
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
|
||||
{
|
||||
for (uint32_t xx = 0; xx < 11 && numInstances < idb->num; ++xx, ++numInstances)
|
||||
{
|
||||
float* mtx = (float*)data;
|
||||
bx::mtxRotateXY(mtx, time + xx*0.21f, time + yy*0.37f);
|
||||
mtx[12] = -15.0f + float(xx)*3.0f;
|
||||
mtx[13] = -15.0f + float(yy)*3.0f;
|
||||
mtx[14] = 0.0f;
|
||||
float view[16];
|
||||
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
|
||||
|
||||
float* color = (float*)&data[64];
|
||||
color[0] = sinf(time+float(xx)/11.0f)*0.5f+0.5f;
|
||||
color[1] = cosf(time+float(yy)/11.0f)*0.5f+0.5f;
|
||||
color[2] = sinf(time*3.0f)*0.5f+0.5f;
|
||||
color[3] = 1.0f;
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
|
||||
data += instanceStride;
|
||||
}
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
//
|
||||
// Use HMD's width/height since HMD's internal frame buffer size
|
||||
// might be much larger than window size.
|
||||
bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
}
|
||||
|
||||
// Set vertex and index buffer.
|
||||
bgfx::setVertexBuffer(vbh);
|
||||
bgfx::setIndexBuffer(ibh);
|
||||
const uint16_t instanceStride = 80;
|
||||
const bgfx::InstanceDataBuffer* idb = bgfx::allocInstanceDataBuffer(121, instanceStride);
|
||||
if (NULL != idb)
|
||||
{
|
||||
uint8_t* data = idb->data;
|
||||
|
||||
// Set instance data buffer.
|
||||
bgfx::setInstanceDataBuffer(idb);
|
||||
// Write instance data for 11x11 cubes.
|
||||
for (uint32_t yy = 0, numInstances = 0; yy < 11 && numInstances < idb->num; ++yy)
|
||||
{
|
||||
for (uint32_t xx = 0; xx < 11 && numInstances < idb->num; ++xx, ++numInstances)
|
||||
{
|
||||
float* mtx = (float*)data;
|
||||
bx::mtxRotateXY(mtx, time + xx*0.21f, time + yy*0.37f);
|
||||
mtx[12] = -15.0f + float(xx)*3.0f;
|
||||
mtx[13] = -15.0f + float(yy)*3.0f;
|
||||
mtx[14] = 0.0f;
|
||||
|
||||
// Set render states.
|
||||
bgfx::setState(BGFX_STATE_DEFAULT);
|
||||
float* color = (float*)&data[64];
|
||||
color[0] = sinf(time+float(xx)/11.0f)*0.5f+0.5f;
|
||||
color[1] = cosf(time+float(yy)/11.0f)*0.5f+0.5f;
|
||||
color[2] = sinf(time*3.0f)*0.5f+0.5f;
|
||||
color[3] = 1.0f;
|
||||
|
||||
// Submit primitive for rendering to view 0.
|
||||
bgfx::submit(0, program);
|
||||
data += instanceStride;
|
||||
}
|
||||
}
|
||||
|
||||
// Set vertex and index buffer.
|
||||
bgfx::setVertexBuffer(m_vbh);
|
||||
bgfx::setIndexBuffer(m_ibh);
|
||||
|
||||
// Set instance data buffer.
|
||||
bgfx::setInstanceDataBuffer(idb);
|
||||
|
||||
// Set render states.
|
||||
bgfx::setState(BGFX_STATE_DEFAULT);
|
||||
|
||||
// Submit primitive for rendering to view 0.
|
||||
bgfx::submit(0, m_program);
|
||||
}
|
||||
}
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
bgfx::destroyIndexBuffer(ibh);
|
||||
bgfx::destroyVertexBuffer(vbh);
|
||||
bgfx::destroyProgram(program);
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t m_debug;
|
||||
uint32_t m_reset;
|
||||
bgfx::VertexBufferHandle m_vbh;
|
||||
bgfx::IndexBufferHandle m_ibh;
|
||||
bgfx::ProgramHandle m_program;
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
int64_t m_timeOffset;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleInstancing);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
4
3rdparty/bgfx/examples/06-bump/bump.cpp
vendored
4
3rdparty/bgfx/examples/06-bump/bump.cpp
vendored
@ -103,7 +103,7 @@ static const uint16_t s_cubeIndices[36] =
|
||||
21, 23, 22,
|
||||
};
|
||||
|
||||
class Bump : public entry::AppI
|
||||
class ExampleBump : public entry::AppI
|
||||
{
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
@ -387,4 +387,4 @@ class Bump : public entry::AppI
|
||||
int64_t m_timeOffset;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(Bump);
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleBump);
|
||||
|
3
3rdparty/bgfx/examples/06-bump/makefile
vendored
3
3rdparty/bgfx/examples/06-bump/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
3
3rdparty/bgfx/examples/07-callback/makefile
vendored
3
3rdparty/bgfx/examples/07-callback/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
3
3rdparty/bgfx/examples/08-update/makefile
vendored
3
3rdparty/bgfx/examples/08-update/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
6
3rdparty/bgfx/examples/08-update/update.cpp
vendored
6
3rdparty/bgfx/examples/08-update/update.cpp
vendored
@ -115,10 +115,10 @@ static void updateTextureCubeRectBgra8(bgfx::TextureHandle _handle, uint8_t _sid
|
||||
static const uint32_t m_textureside = 512;
|
||||
static const uint32_t m_texture2dSize = 256;
|
||||
|
||||
class Update : public entry::AppI
|
||||
class ExampleUpdate : public entry::AppI
|
||||
{
|
||||
public:
|
||||
Update()
|
||||
ExampleUpdate()
|
||||
: m_cube(m_textureside)
|
||||
{
|
||||
}
|
||||
@ -575,4 +575,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(Update);
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleUpdate);
|
||||
|
4
3rdparty/bgfx/examples/09-hdr/hdr.cpp
vendored
4
3rdparty/bgfx/examples/09-hdr/hdr.cpp
vendored
@ -139,7 +139,7 @@ inline float square(float _x)
|
||||
return _x*_x;
|
||||
}
|
||||
|
||||
class HDR : public entry::AppI
|
||||
class ExampleHDR : public entry::AppI
|
||||
{
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
@ -561,4 +561,4 @@ class HDR : public entry::AppI
|
||||
float m_time;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(HDR);
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleHDR);
|
||||
|
3
3rdparty/bgfx/examples/09-hdr/makefile
vendored
3
3rdparty/bgfx/examples/09-hdr/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
4
3rdparty/bgfx/examples/12-lod/lod.cpp
vendored
4
3rdparty/bgfx/examples/12-lod/lod.cpp
vendored
@ -23,7 +23,7 @@ static const KnightPos knightTour[8*4] =
|
||||
{7,1}, {6,3}, {5,1}, {7,0}, {6,2}, {4,3}, {3,1}, {2,3},
|
||||
};
|
||||
|
||||
class Lod : public entry::AppI
|
||||
class ExampleLod : public entry::AppI
|
||||
{
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
@ -316,4 +316,4 @@ class Lod : public entry::AppI
|
||||
bool m_transitions;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(Lod);
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleLod);
|
||||
|
3
3rdparty/bgfx/examples/12-lod/makefile
vendored
3
3rdparty/bgfx/examples/12-lod/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2013 Milos Tosic. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
3
3rdparty/bgfx/examples/13-stencil/makefile
vendored
3
3rdparty/bgfx/examples/13-stencil/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2013-2014 Dario Manesku. All rights reserved.
|
||||
# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
@ -15,3 +15,4 @@ rebuild:
|
||||
@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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user