Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2228)

Unified Diff: core/cross/command_buffer/effect_cb.cc

Issue 147237: Adding GetStreamInfo functionality (and passing corresponding unit test). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/cross/command_buffer/effect_cb.cc
===================================================================
--- core/cross/command_buffer/effect_cb.cc (revision 19749)
+++ core/cross/command_buffer/effect_cb.cc (working copy)
@@ -49,6 +49,7 @@
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 @@
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 @@
}
}
+
+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
« command_buffer/service/win/d3d9/effect_d3d9.cc ('K') | « core/cross/command_buffer/effect_cb.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698