Commit 1730b2df by Corentin Wallez

vertex_routine_fuzzer: Get source from `data`

BUG=swiftshader:86 Change-Id: Ia57c894170e790cdd1ea2fe3b92bbba7f643ba64 Reviewed-on: https://swiftshader-review.googlesource.com/13368Tested-by: 's avatarCorentin Wallez <cwallez@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent b6f0e40b
......@@ -70,6 +70,30 @@ class FakeVS : public glsl::Shader {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
// Data layout:
//
// byte: boolean states
// {
// byte: stream type
// byte: stream count and normalized
// } [MAX_VERTEX_INPUTS]
// {
// byte[32]: reserved sampler state
// } [VERTEX_TEXTURE_IMAGE_UNITS]
//
// char source[] // null terminated
const size_t kHeaderSize = 1 + 2 * sw::MAX_VERTEX_INPUTS + 32 * sw::VERTEX_TEXTURE_IMAGE_UNITS;
if(size <= kHeaderSize)
{
return 0;
}
if (data[size -1] != 0)
{
return 0;
}
std::unique_ptr<ScopedPoolAllocatorAndTLS> allocatorAndTLS(new ScopedPoolAllocatorAndTLS);
std::unique_ptr<sw::VertexShader> shader(new sw::VertexShader);
std::unique_ptr<FakeVS> fakeVS(new FakeVS(shader.get()));
......@@ -98,8 +122,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
glslCompiler->Init(resources);
const char* glslSource = "void main() {gl_Position = vec4(1.0);}";
const char* glslSource = reinterpret_cast<const char*>(data + kHeaderSize);
if (!glslCompiler->compile(&glslSource, 1, SH_OBJECT_CODE))
{
return 0;
......@@ -109,24 +132,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
sw::VertexProcessor::State state;
// Data layout:
//
// byte: boolean states
// {
// byte: stream type
// byte: stream count and normalized
// } [MAX_VERTEX_INPUTS]
// {
// byte[32]: reserved sampler state
// } [VERTEX_TEXTURE_IMAGE_UNITS]
const int state_size = 1 + 2 * sw::MAX_VERTEX_INPUTS + 32 * sw::VERTEX_TEXTURE_IMAGE_UNITS;
if(size < state_size)
{
return 0;
}
state.textureSampling = bytecodeShader->containsTextureSampling();
state.positionRegister = bytecodeShader->getPositionRegister();
state.pointSizeRegister = bytecodeShader->getPointSizeRegister();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment