Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "gpu/command_buffer/service/memory_shader_cache.h" | |
| 6 #include "base/bind.h" | |
| 7 #include "base/file_path.h" | |
| 8 #include "net/disk_cache/disk_cache.h" | |
| 9 #include "ui/gl/gl_bindings.h" | |
| 10 | |
| 11 using disk_cache::Backend; | |
| 12 | |
| 13 namespace gpu { | |
| 14 | |
| 15 //void thing(int a) { | |
| 16 // fprintf(stderr, "got %i from cache callback\n", a); | |
| 17 //} | |
| 18 | |
| 19 MemoryShaderCache::MemoryShaderCache() { | |
| 20 // Backend* backend; | |
| 21 // const FilePath path("shaders"); | |
| 22 // disk_cache::CreateCacheBackend(net::MEMORY_CACHE, path, | |
| 23 // 16 * 1024 * 1024, false, NULL, NULL, &backend, base::Bind(&thing)); | |
| 24 // cache_backend_ = scoped_ptr<Backend>(backend); | |
| 25 } | |
| 26 | |
| 27 MemoryShaderCache::~MemoryShaderCache() { } | |
| 28 | |
| 29 bool MemoryShaderCache::isShaderCacheEnabled() { | |
| 30 #if defined(OS_MACOSX) | |
|
greggman
2012/06/15 08:10:24
You need to call glGetString and check for GL_ARB_
dmurph
2012/06/15 16:40:23
Yeah, I ended up not using this method, I'll put t
| |
| 31 return false; | |
| 32 #else | |
| 33 return true; | |
| 34 #endif | |
| 35 } | |
| 36 | |
| 37 CompiledShaderStatus MemoryShaderCache::getShaderCompilationStatus( | |
| 38 const char* shader_src) { | |
|
greggman
2012/06/15 08:10:24
would it be better if all of these functions took
dmurph
2012/06/15 16:40:23
Yeah, good idea :)
| |
| 39 CachedShaderKey key(shader_src, "", "", 0, 0); | |
| 40 return shader_status_[key]; | |
|
greggman
2012/06/15 08:10:24
If you are just trying to find a key you should ca
dmurph
2012/06/15 16:40:23
It wasn't, thanks for catching this, I'm not super
| |
| 41 } | |
| 42 | |
| 43 void MemoryShaderCache::setShaderCompilationStatus(const char* shader_src, | |
| 44 CompiledShaderStatus status) { | |
| 45 CachedShaderKey key(shader_src, "", "", 0, 0); | |
| 46 shader_status_[key] = status; | |
| 47 } | |
| 48 | |
| 49 LinkedProgramStatus MemoryShaderCache::getLinkedProgramStatus( | |
| 50 const char* untranslated_a, const char* untranslated_b) { | |
| 51 CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); | |
| 52 return link_status_[key]; | |
| 53 } | |
| 54 | |
| 55 void MemoryShaderCache::setLinkedProgramStatus(const char* untranslated_a, | |
| 56 const char* untranslated_b, LinkedProgramStatus status) { | |
| 57 CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); | |
| 58 link_status_[key] = status; | |
| 59 } | |
| 60 | |
| 61 void MemoryShaderCache::getLinkedProgram(const char* untranslated_a, | |
| 62 const char* untranslated_b, GLsizei* length, GLenum* binaryFormat, | |
| 63 const GLvoid** binary) { | |
| 64 CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); | |
| 65 StoreValue value = store_[key]; | |
| 66 *length = value.length; | |
| 67 *binaryFormat = value.format; | |
| 68 *binary = value.data; | |
| 69 } | |
| 70 | |
| 71 void MemoryShaderCache::setLinkedProgram(const char* untranslated_a, | |
| 72 const char* untranslated_b, GLsizei length, GLenum binaryFormat, | |
| 73 GLvoid* binary) { | |
| 74 CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); | |
| 75 StoreValue value(length, binaryFormat, binary); | |
| 76 store_[key] = value; | |
| 77 } | |
| 78 | |
| 79 } // namespace gpu | |
| OLD | NEW |