Skip to content

Commit

Permalink
Integrating latest fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
haroonq committed Jun 8, 2018
1 parent c7e2014 commit 05645f0
Show file tree
Hide file tree
Showing 19 changed files with 164 additions and 28 deletions.
9 changes: 9 additions & 0 deletions WORKSPACE
@@ -1,3 +1,6 @@
load("//dev:custom_rules.bzl", "local_repository_env")
load("//third_party/libfbx:build_defs.bzl", "FBX_BUILD_FILE_CONTENTS")

new_http_archive(
name = "absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/7aacab8ae05d.tar.gz"],
Expand Down Expand Up @@ -100,6 +103,12 @@ new_http_archive(
strip_prefix = "KTX-Software-0e6b5c7c21818044da33da5f39534ea268fed181",
)

local_repository_env(
name = "libfbx",
env = "FBX_SDK_ROOT",
build_file = FBX_BUILD_FILE_CONTENTS,
)

new_http_archive(
name = "libjpeg_turbo",
urls = ["https://github.com/libjpeg-turbo/libjpeg-turbo/archive/3041cf67ffdc.tar.gz"],
Expand Down
16 changes: 16 additions & 0 deletions dev/custom_rules.bzl
@@ -0,0 +1,16 @@
# Custom rules for OSS bazel project.

def _local_repository(ctx):
ctx.symlink(ctx.os.environ[ctx.attr.env], ctx.attr.env)
ctx.file("BUILD", ctx.attr.build_file)
return None

local_repository_env = repository_rule(
implementation = _local_repository,
local = True,
attrs = {
"env": attr.string(mandatory=True),
"build_file": attr.string(mandatory=True),
}
)

1 change: 1 addition & 0 deletions lullaby/contrib/device_tooltips/BUILD
Expand Up @@ -21,6 +21,7 @@ cc_library(
"//lullaby/systems/text",
"//lullaby/systems/transform",
"//lullaby/util:entity",
"//lullaby/util:enum_hash",
"//lullaby/util:registry",
],
)
3 changes: 2 additions & 1 deletion lullaby/contrib/device_tooltips/device_tooltips.h
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include "lullaby/modules/dispatcher/dispatcher.h"
#include "lullaby/modules/input/input_manager.h"
#include "lullaby/util/entity.h"
#include "lullaby/util/enum_hash.h"
#include "lullaby/util/registry.h"

namespace lull {
Expand Down Expand Up @@ -83,7 +84,7 @@ class DeviceTooltips {

std::unordered_map<DeviceButtonPair, Tooltip, DeviceButtonPairHash> tooltips_;

std::unordered_map<InputManager::DeviceType, Entity> devices_;
std::unordered_map<InputManager::DeviceType, Entity, EnumHash> devices_;

Dispatcher::ScopedConnection device_connnected_connection_;
Dispatcher::ScopedConnection show_tooltip_connection_;
Expand Down
14 changes: 9 additions & 5 deletions lullaby/examples/hello_world/data/hello_world.json
Expand Up @@ -23,9 +23,9 @@
"def": {
"shader": "shaders/text.fplshader",
"color": {
"r": 1.0,
"g": 1.0,
"b": 1.0,
"r": 0.0,
"g": 0.5,
"b": 0.0,
"a": 1.0
}
}
Expand All @@ -35,8 +35,12 @@
"fonts": [
"Roboto-Regular.ttf"
],
"text": "Hello World!",
"font_size": 0.2,
"text": "Hello World!\nThis is a Lullaby example.",
"font_size": 0.5,
"bounds": {
"x": 10.0,
"y": 0.0,
},
"vertical_alignment": "Center"
}
}]
Expand Down
23 changes: 22 additions & 1 deletion lullaby/systems/render/BUILD
Expand Up @@ -211,6 +211,7 @@ cc_library(
"//lullaby/util:flatbuffer_reader",
"//lullaby/util:async_processor",
"//lullaby/util:buffered_data",
"//lullaby/util:enum_hash",
"//lullaby/util:filename",
"//lullaby/util:fixed_string",
"//lullaby/util:resource_manager",
Expand All @@ -227,7 +228,6 @@ cc_library(
name = "render_system_mock",
testonly = 1,
srcs = [
"detail/port/default/gpu_profiler.cc",
"testing/mock_render_system_impl.cc",
],
hdrs = [
Expand Down Expand Up @@ -325,6 +325,27 @@ cc_library(
}),
)

# Test-only target that doesn't include any GL.
cc_library(
name = "profiler_no_gl",
testonly = 1,
srcs = [
"detail/port/default/gpu_profiler.cc",
"detail/profiler.cc",
],
hdrs = [
"detail/gpu_profiler.h",
"detail/profiler.h",
],
deps = [
":render",
"//lullaby/util:clock",
"//lullaby/util:logging",
"//lullaby/util:time",
"//lullaby/util:typeid",
],
)

cc_library(
name = "render_helpers",
srcs = ["render_helpers.cc"],
Expand Down
13 changes: 8 additions & 5 deletions lullaby/systems/render/fpl/render_system_fpl.cc
Expand Up @@ -1178,6 +1178,14 @@ void RenderSystemFpl::SetClearColor(float r, float g, float b, float a) {
clear_color_ = mathfu::vec4(r, g, b, a);
}

void RenderSystemFpl::SetClearParams(HashValue pass,
const ClearParams& clear_params) {
if (CheckBit(clear_params.clear_options, RenderClearParams::kColor)) {
SetClearColor(clear_params.color_value.x, clear_params.color_value.y,
clear_params.color_value.z, clear_params.color_value.w);
}
}

void RenderSystemFpl::BeginFrame() {
LULLABY_CPU_TRACE_CALL();
GL_CALL(glClearColor(clear_color_.x, clear_color_.y, clear_color_.z,
Expand Down Expand Up @@ -1826,11 +1834,6 @@ void RenderSystemFpl::SetSortOrderOffset(Entity /*e*/, HashValue pass,
LOG(DFATAL) << "This feature is only implemented in RenderSystemNext.";
}

void RenderSystemFpl::SetClearParams(HashValue pass,
const ClearParams& clear_params) {
LOG(DFATAL) << "This feature is only implemented in RenderSystemNext.";
}

void RenderSystemFpl::SetRenderState(HashValue pass,
const fplbase::RenderState& render_state) {
LOG(DFATAL) << "This feature is only implemented in RenderSystemNext.";
Expand Down
4 changes: 2 additions & 2 deletions lullaby/systems/render/next/material.cc
Expand Up @@ -237,8 +237,8 @@ void Material::Bind(int max_texture_units) {
}

void Material::CopyUniforms(const Material& rhs) {
for (auto& iter : uniform_index_map_) {
Uniform& uniform = uniforms_[iter.second];
for (const auto& iter : rhs.uniform_index_map_) {
const Uniform& uniform = rhs.uniforms_[iter.second];
const uint8_t* bytes = uniform.data.GetData<uint8_t>();
const size_t size = uniform.data.Size();
SetUniform(iter.first, uniform.data.Type(), {bytes, size});
Expand Down
3 changes: 2 additions & 1 deletion lullaby/systems/render/next/material.h
Expand Up @@ -25,6 +25,7 @@ limitations under the License.
#include "lullaby/systems/render/next/uniform.h"
#include "lullaby/systems/render/shader.h"
#include "lullaby/systems/render/texture.h"
#include "lullaby/util/enum_hash.h"
#include "lullaby/util/hash.h"
#include "lullaby/util/optional.h"
#include "lullaby/util/variant.h"
Expand Down Expand Up @@ -117,7 +118,7 @@ class Material {
std::vector<Uniform> uniforms_;
std::vector<TexturePtr> textures_;
std::unordered_map<HashValue, size_t> uniform_index_map_;
std::unordered_map<MaterialTextureUsage, size_t> sampler_index_map_;
std::unordered_map<MaterialTextureUsage, size_t, EnumHash> sampler_index_map_;

// Render State.
Optional<BlendStateT> blend_state_;
Expand Down
3 changes: 2 additions & 1 deletion lullaby/systems/render/next/next_renderer.cc
Expand Up @@ -175,7 +175,8 @@ NextRenderer::NextRenderer() {
}

// Check for ASTC.
#if defined(GL_COMPRESSED_RGBA_ASTC_4x4_KHR)
#if defined(GL_COMPRESSED_RGBA_ASTC_4x4_KHR) and \
defined(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR)
// If we have the ASTC type enums defined, check using them.
gContextCapabilities.supports_astc_textures = true;

Expand Down
2 changes: 1 addition & 1 deletion lullaby/systems/render/next/shader_data.cc
Expand Up @@ -348,7 +348,7 @@ void PrintSnippetsNames(string_view prefix_string,
} // namespace

ShaderData::ShaderData(const ShaderDefT& def) {
const ShaderCreateParams params;
const ShaderCreateParams params{};
BuildFromShaderDefT(def, params);
}

Expand Down
2 changes: 1 addition & 1 deletion lullaby/tools/anim_pipeline/BUILD
Expand Up @@ -24,7 +24,7 @@ cc_library(
],
deps = [
":animation_lib",
"@libfbx//:2016_1_2",
"@libfbx//:libfbx",
"//lullaby/util:logging",
"//lullaby/tools/common:fbx_utils",
],
Expand Down
1 change: 1 addition & 0 deletions lullaby/tools/anim_pipeline/import_fbx.cc
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

#include <fbxsdk.h>
#include <unordered_map>
#include "lullaby/util/logging.h"
#include "lullaby/tools/anim_pipeline/animation.h"
#include "lullaby/tools/common/fbx_utils.h"
Expand Down
2 changes: 1 addition & 1 deletion lullaby/tools/common/BUILD
Expand Up @@ -15,7 +15,7 @@ cc_library(
"fbx_utils.h",
],
deps = [
"//third_party/libfbx:libfbx",
"@libfbx//:libfbx",
"//:fbs",
],
)
Expand Down
2 changes: 1 addition & 1 deletion lullaby/tools/model_pipeline/BUILD
Expand Up @@ -53,7 +53,7 @@ cc_library(
copts = ["-Wno-null-dereference"],
deps = [
":model_lib",
"//third_party/libfbx:libfbx",
"@libfbx//:libfbx",
"//:fbs",
"//lullaby/util:common_types",
"//lullaby/tools/common:fbx_utils",
Expand Down
17 changes: 17 additions & 0 deletions lullaby/tools/shader_pipeline/build_shader.cc
Expand Up @@ -30,6 +30,7 @@ namespace lull {
namespace tool {

namespace {
static constexpr int kUnspecifiedVersion = 0;
static constexpr HashValue kAttributeHashPosition = ConstHash("ATTR_POSITION");
static constexpr HashValue kAttributeHashUV = ConstHash("ATTR_UV");
static constexpr HashValue kAttributeHashColor = ConstHash("ATTR_COLOR");
Expand Down Expand Up @@ -59,6 +60,21 @@ void AddUnique(ValueType value, rapidjson::Value* array,
array->PushBack(value, document->GetAllocator());
}

// Helper function that ensures there is a version in the snippet.
void CheckForVersion(rapidjson::Value* snippet, rapidjson::Document* document) {
if (!snippet || !document) {
return;
}

if (!snippet->HasMember("versions")) {
rapidjson::Value versions(rapidjson::kArrayType);
rapidjson::Value version(rapidjson::kObjectType);
version.AddMember("lang", "GL_Compat", document->GetAllocator());
versions.PushBack(version, document->GetAllocator());
snippet->AddMember("versions", versions, document->GetAllocator());
}
}

// Helper function to create the environment flags of a snippet.
void CreateSnippetEnvironmentFlags(rapidjson::Value* snippet,
rapidjson::Document* document) {
Expand Down Expand Up @@ -360,6 +376,7 @@ bool AddSnippetsFromJson(const std::string& json_string,
for (rapidjson::Value::ValueIterator iter = snippets.Begin();
iter != snippets.End(); ++iter) {
rapidjson::Value* snippet = &*iter;
CheckForVersion(snippet, &json);
CreateSnippetEnvironmentFlags(snippet, &json);
ValidateAndProcessUniforms(snippet, &json);
ProcessSnippetCodeSection("code", snippet, &json);
Expand Down
32 changes: 29 additions & 3 deletions schemas/lull/shader_def.fbs
Expand Up @@ -65,19 +65,48 @@ enum ShaderStageType : ushort {
Fragment,
}

/// Types of programmable shader stages.
enum ShaderLanguage : ushort {
/// GL Shading Language Compatible across GLSL and GLSL_ES. Version mapping
/// attempts to keep OpenGL ES and OpenGL Core compatible and uses OpenGL ES
/// as the base for versioning.
/// Sample mapping: 100 = [100 GLES, 110 GL], 300 = [300 GLES, 330 GL].
GL_Compat,
/// OpenGL Shading Language. Versions map directly to the GLSL versions.
GLSL,
/// OpenGL ES Shading Language. Versions map directly to GLSL ES versions.
GLSL_ES,
}

table ShaderSnippetVersionDef {
/// Shader language defined for the snippet.
lang: ShaderLanguage;
/// Minimum shading language version supported.
/// [0 = no minimum version].
min_version: int;
/// Maximum shading language version supported.
/// [0 = no maximum version].
max_version: int;
}

/// Snippet containing shader source code or reference to a file containing the
/// source code.
table ShaderSnippetDef {
// Name identifier for this snippet. This is mostly for debug purposes.
name: string;

// Shading language versions supported by this shader snippet.
versions: [ShaderSnippetVersionDef];

/// Features implemented by this snippet.
features: [uint] (hashvalue);
/// Environment flags required for this snippet to work.
environment: [uint] (hashvalue);

/// Uniforms used by this snippet's shader code.
uniforms: [ShaderUniformDef];
/// Samplers used by this snippet's shader code.
samplers: [ShaderSamplerDef];
/// Input data received by the snippet in the form of attributes or varying.
inputs: [ShaderAttributeDef];
/// Output data sent by the snippet in the form of attributes or varying.
Expand All @@ -87,9 +116,6 @@ table ShaderSnippetDef {
code: string;
/// Shader main() function implementation code for this snippet.
main_code: string;

/// Samplers used by this snippet's shader code.
samplers: [ShaderSamplerDef];
}

/// A shader stage and associated snippets.
Expand Down
20 changes: 15 additions & 5 deletions third_party/libfbx/BUILD
Expand Up @@ -2,12 +2,22 @@ package(
default_visibility = ["//visibility:public"],
)

licenses(["notice"]) # Apache 2.0

cc_library(
name = "libfbx",
linkopts = [
"-L/usr/lib/gcc4/x64/release -lfbxsdk"
srcs = [
"FBX_SDK_ROOT/lib/gcc4/x64/release/libfbxsdk.a"
],
includes = ["include"],
hdrs = [
"FBX_SDK_ROOT/include/fbxsdk.h"
] + glob([
"FBX_SDK_ROOT/include/fbxsdk/**/*.h"
]),
includes = [
"FBX_SDK_ROOT/include",
"."
],
linkopts = [
"-ldl",
"-pthread",
]
)
25 changes: 25 additions & 0 deletions third_party/libfbx/build_defs.bzl
@@ -0,0 +1,25 @@
FBX_BUILD_FILE_CONTENTS = """
package(
default_visibility = ["//visibility:public"],
)
cc_library(
name = "libfbx",
srcs = [
"FBX_SDK_ROOT/lib/gcc4/x64/release/libfbxsdk.a"
],
hdrs = [
"FBX_SDK_ROOT/include/fbxsdk.h"
] + glob([
"FBX_SDK_ROOT/include/fbxsdk/**/*.h"
]),
includes = [
"FBX_SDK_ROOT/include",
"."
],
linkopts = [
"-ldl",
"-pthread",
]
)
"""

0 comments on commit 05645f0

Please sign in to comment.