summaryrefslogtreecommitdiffstats
path: root/o3d/core
diff options
context:
space:
mode:
authorrlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 23:28:00 +0000
committerrlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 23:28:00 +0000
commitac300913ded24c0e6887c72fa48435dc671bd16c (patch)
tree89a09fe8171122c66f74b1d6fbf2ec6df35ff37d /o3d/core
parentdcdae9eeabbf866f98d7fab10096bb19054458cc (diff)
downloadchromium_src-ac300913ded24c0e6887c72fa48435dc671bd16c.zip
chromium_src-ac300913ded24c0e6887c72fa48435dc671bd16c.tar.gz
chromium_src-ac300913ded24c0e6887c72fa48435dc671bd16c.tar.bz2
Adding GetStreamInfo functionality (and passing corresponding unit test).
Review URL: http://codereview.chromium.org/147237 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core')
-rw-r--r--o3d/core/cross/command_buffer/effect_cb.cc59
-rw-r--r--o3d/core/cross/command_buffer/effect_cb.h2
2 files changed, 59 insertions, 2 deletions
diff --git a/o3d/core/cross/command_buffer/effect_cb.cc b/o3d/core/cross/command_buffer/effect_cb.cc
index afa9e0f..27afbd7 100644
--- a/o3d/core/cross/command_buffer/effect_cb.cc
+++ b/o3d/core/cross/command_buffer/effect_cb.cc
@@ -49,6 +49,7 @@ using command_buffer::CommandBufferEntry;
using command_buffer::CommandBufferHelper;
using command_buffer::ResourceID;
namespace effect_param = command_buffer::effect_param;
+namespace vertex_struct = command_buffer::vertex_struct;
EffectCB::EffectCB(ServiceLocator *service_locator, RendererCB *renderer)
: Effect(service_locator),
@@ -125,6 +126,11 @@ bool EffectCB::LoadFromFXString(const String& source) {
return false;
}
}
+ if (!effect_helper.GetEffectStreams(resource_id, &stream_descs_)) {
+ O3D_ERROR(service_locator()) << "Failed to get streams.";
+ Destroy();
+ return false;
+ }
set_source(source);
return true;
}
@@ -200,8 +206,59 @@ void EffectCB::GetParameterInfo(EffectParameterInfoArray *array) {
}
}
+
+static bool CBSemanticToO3DSemantic(
+ vertex_struct::Semantic semantic,
+ unsigned int semantic_index,
+ Stream::Semantic *out_semantic,
+ unsigned int *out_semantic_index) {
+ switch (semantic) {
+ case vertex_struct::POSITION:
+ if (semantic_index != 0) return false;
+ *out_semantic = Stream::POSITION;
+ *out_semantic_index = 0;
+ return true;
+ case vertex_struct::NORMAL:
+ if (semantic_index != 0) return false;
+ *out_semantic = Stream::NORMAL;
+ *out_semantic_index = 0;
+ return true;
+ case vertex_struct::COLOR:
+ if (semantic_index > 1) return false;
+ *out_semantic = Stream::COLOR;
+ *out_semantic_index = semantic_index;
+ return true;
+ case vertex_struct::TEX_COORD:
+ if (semantic_index == 6) {
+ *out_semantic = Stream::TANGENT;
+ *out_semantic_index = 0;
+ return true;
+ } else if (semantic_index == 7) {
+ *out_semantic = Stream::BINORMAL;
+ *out_semantic_index = 0;
+ return true;
+ } else {
+ *out_semantic = Stream::TEXCOORD;
+ *out_semantic_index = semantic_index;
+ return true;
+ }
+ default:
+ return false;
+ }
+}
void EffectCB::GetStreamInfo(EffectStreamInfoArray *array) {
- // TODO(rlp)
+ DCHECK(array);
+ array->clear();
+ for (unsigned int i = 0; i < stream_descs_.size(); ++i) {
+ Stream::Semantic semantic;
+ unsigned int semantic_index;
+ if (CBSemanticToO3DSemantic(stream_descs_[i].semantic,
+ stream_descs_[i].semantic_index,
+ &semantic,
+ &semantic_index)) {
+ array->push_back(EffectStreamInfo(semantic, semantic_index));
+ }
+ }
}
} // namespace o3d
diff --git a/o3d/core/cross/command_buffer/effect_cb.h b/o3d/core/cross/command_buffer/effect_cb.h
index a50638e..3d310bc 100644
--- a/o3d/core/cross/command_buffer/effect_cb.h
+++ b/o3d/core/cross/command_buffer/effect_cb.h
@@ -75,9 +75,9 @@ class EffectCB : public Effect {
// The command buffer resource ID for the effect.
command_buffer::ResourceID resource_id_;
std::vector<EffectHelper::EffectParamDesc> param_descs_;
+ std::vector<EffectHelper::EffectStreamDesc> stream_descs_;
// A generation counter to dirty ParamCacheCBs.
unsigned int generation_;
-
// The renderer that created this effect.
RendererCB *renderer_;
DISALLOW_IMPLICIT_CONSTRUCTORS(EffectCB);