Commit 1845d5ee by Chris Forbes

Replace Shader,VertexShader,PixelShader with SpirvShader

Also deletes tons of fixed-function-centric stuff that will never be used by the Vulkan backend. Very little of the SPIRV integration actually does anything interesting yet (we don't generate code) but this wires on the new shader representation. Bug: b/120799499 Change-Id: Ib76e2086113098aebd526a0da461689d4344e8c2 Reviewed-on: https://swiftshader-review.googlesource.com/c/23090Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 64c44b0c
......@@ -16,10 +16,9 @@
#include "Primitive.hpp"
#include "Surface.hpp"
#include "Pipeline/PixelShader.hpp"
#include "Pipeline/VertexShader.hpp"
#include "System/Memory.hpp"
#include "Vulkan/VkDebug.hpp"
#include "Pipeline/SpirvShader.hpp"
#include <string.h>
......@@ -27,7 +26,6 @@ namespace sw
{
extern bool perspectiveCorrection;
bool halfIntegerCoordinates = false; // Pixel centers are not at integer coordinates
bool booleanFaceRegister = false;
bool fullPixelPositionRegister = false;
bool leadingVertexFirst = false; // Flat shading uses first vertex, else last
......@@ -724,16 +722,6 @@ namespace sw
return true;
}
unsigned short Context::pixelShaderModel() const
{
return pixelShader ? pixelShader->getShaderModel() : 0x0000;
}
unsigned short Context::vertexShaderModel() const
{
return vertexShader ? vertexShader->getShaderModel() : 0x0000;
}
int Context::getMultiSampleCount() const
{
return renderTarget[0] ? renderTarget[0]->getMultiSampleCount() : 1;
......@@ -774,6 +762,6 @@ namespace sw
bool Context::colorUsed()
{
return colorWriteActive() || alphaTestActive() || (pixelShader && pixelShader->containsKill());
return colorWriteActive() || alphaTestActive() || (pixelShader && pixelShader->getModes().ContainsKill);
}
}
......@@ -27,6 +27,7 @@ namespace sw
class Surface;
class PixelShader;
class VertexShader;
class SpirvShader;
struct Triangle;
struct Primitive;
struct Vertex;
......@@ -153,9 +154,6 @@ namespace sw
VkLogicOp colorLogicOp();
unsigned short pixelShaderModel() const;
unsigned short vertexShaderModel() const;
int getMultiSampleCount() const;
DrawType drawType;
......@@ -208,8 +206,8 @@ namespace sw
unsigned int stencilBufferLayer;
// Shaders
const PixelShader *pixelShader;
const VertexShader *vertexShader;
const SpirvShader *pixelShader;
const SpirvShader *vertexShader;
// Instancing
int instanceID;
......
......@@ -17,7 +17,6 @@
#include "Surface.hpp"
#include "Primitive.hpp"
#include "Pipeline/PixelProgram.hpp"
#include "Pipeline/PixelShader.hpp"
#include "Pipeline/Constants.hpp"
#include "Vulkan/VkDebug.hpp"
......@@ -634,8 +633,7 @@ namespace sw
state.shaderID = 0;
}
state.depthOverride = context->pixelShader && context->pixelShader->depthOverride();
state.shaderContainsKill = context->pixelShader ? context->pixelShader->containsKill() : false;
state.depthOverride = context->pixelShader ? context->pixelShader->getModes().DepthReplacing : false;
if(context->alphaTestActive())
{
......@@ -704,61 +702,50 @@ namespace sw
if(state.multiSample > 1 && context->pixelShader)
{
state.centroid = context->pixelShader->containsCentroid();
state.centroid = false;//context->pixelShader->containsCentroid();
}
state.frontFaceCCW = context->frontFacingCCW;
for(unsigned int i = 0; i < 16; i++)
{
if(context->pixelShader)
{
if(context->pixelShader->usesSampler(i))
{
state.sampler[i] = context->sampler[i].samplerState();
}
}
}
const bool point = context->isDrawPoint();
for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
{
for(int component = 0; component < 4; component++)
{
const Shader::Semantic &semantic = context->pixelShader->getInput(interpolant, component);
if(semantic.active())
{
bool flat = point;
switch(semantic.usage)
{
case Shader::USAGE_TEXCOORD: flat = false; break;
case Shader::USAGE_COLOR: flat = semantic.flat || point; break;
}
state.interpolant[interpolant].component |= 1 << component;
if(flat)
{
state.interpolant[interpolant].flat |= 1 << component;
}
}
}
}
if(state.centroid)
{
for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
{
for(int component = 0; component < 4; component++)
{
state.interpolant[interpolant].centroid = context->pixelShader->getInput(interpolant, 0).centroid;
}
}
}
/* TODO: bring back interpolants by some mechanism */
// for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
// {
// for(int component = 0; component < 4; component++)
// {
// const Shader::Semantic &semantic = context->pixelShader->getInput(interpolant, component);
//
// if(semantic.active())
// {
// bool flat = point;
//
// switch(semantic.usage)
// {
// case Shader::USAGE_TEXCOORD: flat = false; break;
// case Shader::USAGE_COLOR: flat = semantic.flat || point; break;
// }
//
// state.interpolant[interpolant].component |= 1 << component;
//
// if(flat)
// {
// state.interpolant[interpolant].flat |= 1 << component;
// }
// }
// }
// }
//
// if(state.centroid)
// {
// for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
// {
// for(int component = 0; component < 4; component++)
// {
// state.interpolant[interpolant].centroid = context->pixelShader->getInput(interpolant, 0).centroid;
// }
// }
// }
state.hash = state.computeHash();
......@@ -771,7 +758,6 @@ namespace sw
if(!routine)
{
const bool integerPipeline = (context->pixelShaderModel() <= 0x0104);
QuadRasterizer *generator = new PixelProgram(state, context->pixelShader);
generator->generate();
routine = (*generator)("PixelRoutine_%0.8X", state.shaderID);
......
......@@ -35,7 +35,6 @@ namespace sw
int shaderID;
bool depthOverride : 1; // TODO: Eliminate by querying shader.
bool shaderContainsKill : 1; // TODO: Eliminate by querying shader.
VkCompareOp depthCompareMode : BITS(VK_COMPARE_OP_END_RANGE);
VkCompareOp alphaCompareMode : BITS(VK_COMPARE_OP_END_RANGE);
......
......@@ -28,7 +28,7 @@ namespace sw
extern int clusterCount;
QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, const PixelShader *pixelShader) : state(state), shader(pixelShader)
QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader) : state(state), spirvShader{spirvShader}
{
}
......@@ -340,11 +340,11 @@ namespace sw
bool QuadRasterizer::interpolateZ() const
{
return state.depthTestActive || (shader && shader->isVPosDeclared() && fullPixelPositionRegister);
return state.depthTestActive || (spirvShader && spirvShader->hasBuiltinInput(spv::BuiltInPosition));
}
bool QuadRasterizer::interpolateW() const
{
return state.perspective || (shader && shader->isVPosDeclared() && fullPixelPositionRegister);
return state.perspective || (spirvShader && spirvShader->hasBuiltinInput(spv::BuiltInPosition));
}
}
......@@ -17,7 +17,7 @@
#include "Rasterizer.hpp"
#include "Pipeline/ShaderCore.hpp"
#include "Pipeline/PixelShader.hpp"
#include "Pipeline/SpirvShader.hpp"
#include "System/Types.hpp"
namespace sw
......@@ -25,7 +25,7 @@ namespace sw
class QuadRasterizer : public Rasterizer
{
public:
QuadRasterizer(const PixelProcessor::State &state, const PixelShader *shader);
QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader);
virtual ~QuadRasterizer();
void generate();
......@@ -51,7 +51,7 @@ namespace sw
Float4 interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective, bool clamp);
const PixelProcessor::State &state;
const PixelShader *const shader;
const SpirvShader *const spirvShader;
private:
void rasterize(Int &yMin, Int &yMax);
......
......@@ -30,6 +30,7 @@
#include "System/Math.hpp"
#include "System/Timer.hpp"
#include "Vulkan/VkDebug.hpp"
#include "Pipeline/SpirvShader.hpp"
#undef max
......@@ -42,7 +43,6 @@ unsigned int maxPrimitives = 1 << 21;
namespace sw
{
extern bool halfIntegerCoordinates; // Pixel centers are not at integer coordinates
extern bool booleanFaceRegister;
extern bool fullPixelPositionRegister;
extern bool leadingVertexFirst; // Flat shading uses first vertex, else last
......@@ -77,7 +77,6 @@ namespace sw
if(!initialized)
{
sw::halfIntegerCoordinates = conventions.halfIntegerCoordinates;
sw::booleanFaceRegister = conventions.booleanFaceRegister;
sw::fullPixelPositionRegister = conventions.fullPixelPositionRegister;
sw::leadingVertexFirst = conventions.leadingVertexFirst;
......@@ -98,14 +97,6 @@ namespace sw
{
queries = 0;
vsDirtyConstF = VERTEX_UNIFORM_VECTORS + 1;
vsDirtyConstI = 16;
vsDirtyConstB = 16;
psDirtyConstF = FRAGMENT_UNIFORM_VECTORS;
psDirtyConstI = 16;
psDirtyConstB = 16;
references = -1;
data = (DrawData*)allocate(sizeof(DrawData));
......@@ -294,14 +285,10 @@ namespace sw
if(queries.size() != 0)
{
draw->queries = new std::list<Query*>();
bool includePrimitivesWrittenQueries = vertexState.transformFeedbackQueryEnabled && vertexState.transformFeedbackEnabled;
for(auto &query : queries)
{
if(includePrimitivesWrittenQueries || (query->type != Query::TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN))
{
++query->reference; // Atomic
draw->queries->push_back(query);
}
++query->reference; // Atomic
draw->queries->push_back(query);
}
}
......@@ -358,24 +345,6 @@ namespace sw
if(context->pixelShader)
{
if(draw->psDirtyConstF)
{
memcpy(&data->ps.c, PixelProcessor::c, sizeof(float4) * draw->psDirtyConstF);
draw->psDirtyConstF = 0;
}
if(draw->psDirtyConstI)
{
memcpy(&data->ps.i, PixelProcessor::i, sizeof(int4) * draw->psDirtyConstI);
draw->psDirtyConstI = 0;
}
if(draw->psDirtyConstB)
{
memcpy(&data->ps.b, PixelProcessor::b, sizeof(bool) * draw->psDirtyConstB);
draw->psDirtyConstB = 0;
}
PixelProcessor::lockUniformBuffers(data->ps.u, draw->pUniformBuffers);
}
else
......@@ -397,31 +366,12 @@ namespace sw
}
}
if(draw->vsDirtyConstF)
{
memcpy(&data->vs.c, VertexProcessor::c, sizeof(float4) * draw->vsDirtyConstF);
draw->vsDirtyConstF = 0;
}
if(draw->vsDirtyConstI)
{
memcpy(&data->vs.i, VertexProcessor::i, sizeof(int4) * draw->vsDirtyConstI);
draw->vsDirtyConstI = 0;
}
if(draw->vsDirtyConstB)
{
memcpy(&data->vs.b, VertexProcessor::b, sizeof(bool) * draw->vsDirtyConstB);
draw->vsDirtyConstB = 0;
}
if(context->vertexShader->isInstanceIdDeclared())
if(context->vertexShader->hasBuiltinInput(spv::BuiltInInstanceId))
{
data->instanceID = context->instanceID;
}
VertexProcessor::lockUniformBuffers(data->vs.u, draw->vUniformBuffers);
VertexProcessor::lockTransformFeedbackBuffers(data->vs.t, data->vs.reg, data->vs.row, data->vs.col, data->vs.str, draw->transformFeedbackBuffers);
if(pixelState.stencilActive)
{
......@@ -965,14 +915,6 @@ namespace sw
}
}
for(int i = 0; i < MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; i++)
{
if(draw.transformFeedbackBuffers[i])
{
draw.transformFeedbackBuffers[i]->unlock();
}
}
draw.vertexRoutine->unbind();
draw.setupRoutine->unbind();
draw.pixelRoutine->unbind();
......@@ -1723,92 +1665,6 @@ namespace sw
}
}
void Renderer::loadConstants(const VertexShader *vertexShader)
{
size_t count = vertexShader->getLength();
for(size_t i = 0; i < count; i++)
{
const Shader::Instruction *instruction = vertexShader->getInstruction(i);
if(instruction->opcode == Shader::OPCODE_DEF)
{
int index = instruction->dst.index;
float value[4];
value[0] = instruction->src[0].value[0];
value[1] = instruction->src[0].value[1];
value[2] = instruction->src[0].value[2];
value[3] = instruction->src[0].value[3];
setVertexShaderConstantF(index, value);
}
else if(instruction->opcode == Shader::OPCODE_DEFI)
{
int index = instruction->dst.index;
int integer[4];
integer[0] = instruction->src[0].integer[0];
integer[1] = instruction->src[0].integer[1];
integer[2] = instruction->src[0].integer[2];
integer[3] = instruction->src[0].integer[3];
setVertexShaderConstantI(index, integer);
}
else if(instruction->opcode == Shader::OPCODE_DEFB)
{
int index = instruction->dst.index;
int boolean = instruction->src[0].boolean[0];
setVertexShaderConstantB(index, &boolean);
}
}
}
void Renderer::loadConstants(const PixelShader *pixelShader)
{
if(!pixelShader) return;
size_t count = pixelShader->getLength();
for(size_t i = 0; i < count; i++)
{
const Shader::Instruction *instruction = pixelShader->getInstruction(i);
if(instruction->opcode == Shader::OPCODE_DEF)
{
int index = instruction->dst.index;
float value[4];
value[0] = instruction->src[0].value[0];
value[1] = instruction->src[0].value[1];
value[2] = instruction->src[0].value[2];
value[3] = instruction->src[0].value[3];
setPixelShaderConstantF(index, value);
}
else if(instruction->opcode == Shader::OPCODE_DEFI)
{
int index = instruction->dst.index;
int integer[4];
integer[0] = instruction->src[0].integer[0];
integer[1] = instruction->src[0].integer[1];
integer[2] = instruction->src[0].integer[2];
integer[3] = instruction->src[0].integer[3];
setPixelShaderConstantI(index, integer);
}
else if(instruction->opcode == Shader::OPCODE_DEFB)
{
int index = instruction->dst.index;
int boolean = instruction->src[0].boolean[0];
setPixelShaderConstantB(index, &boolean);
}
}
}
void Renderer::setIndexBuffer(Resource *indexBuffer)
{
context->indexBuffer = indexBuffer;
......@@ -2131,120 +1987,14 @@ namespace sw
context->rasterizerDiscard = rasterizerDiscard;
}
void Renderer::setPixelShader(const PixelShader *shader)
void Renderer::setPixelShader(const SpirvShader *shader)
{
context->pixelShader = shader;
loadConstants(shader);
}
void Renderer::setVertexShader(const VertexShader *shader)
void Renderer::setVertexShader(const SpirvShader *shader)
{
context->vertexShader = shader;
loadConstants(shader);
}
void Renderer::setPixelShaderConstantF(unsigned int index, const float value[4], unsigned int count)
{
for(unsigned int i = 0; i < DRAW_COUNT; i++)
{
if(drawCall[i]->psDirtyConstF < index + count)
{
drawCall[i]->psDirtyConstF = index + count;
}
}
for(unsigned int i = 0; i < count; i++)
{
PixelProcessor::setFloatConstant(index + i, value);
value += 4;
}
}
void Renderer::setPixelShaderConstantI(unsigned int index, const int value[4], unsigned int count)
{
for(unsigned int i = 0; i < DRAW_COUNT; i++)
{
if(drawCall[i]->psDirtyConstI < index + count)
{
drawCall[i]->psDirtyConstI = index + count;
}
}
for(unsigned int i = 0; i < count; i++)
{
PixelProcessor::setIntegerConstant(index + i, value);
value += 4;
}
}
void Renderer::setPixelShaderConstantB(unsigned int index, const int *boolean, unsigned int count)
{
for(unsigned int i = 0; i < DRAW_COUNT; i++)
{
if(drawCall[i]->psDirtyConstB < index + count)
{
drawCall[i]->psDirtyConstB = index + count;
}
}
for(unsigned int i = 0; i < count; i++)
{
PixelProcessor::setBooleanConstant(index + i, *boolean);
boolean++;
}
}
void Renderer::setVertexShaderConstantF(unsigned int index, const float value[4], unsigned int count)
{
for(unsigned int i = 0; i < DRAW_COUNT; i++)
{
if(drawCall[i]->vsDirtyConstF < index + count)
{
drawCall[i]->vsDirtyConstF = index + count;
}
}
for(unsigned int i = 0; i < count; i++)
{
VertexProcessor::setFloatConstant(index + i, value);
value += 4;
}
}
void Renderer::setVertexShaderConstantI(unsigned int index, const int value[4], unsigned int count)
{
for(unsigned int i = 0; i < DRAW_COUNT; i++)
{
if(drawCall[i]->vsDirtyConstI < index + count)
{
drawCall[i]->vsDirtyConstI = index + count;
}
}
for(unsigned int i = 0; i < count; i++)
{
VertexProcessor::setIntegerConstant(index + i, value);
value += 4;
}
}
void Renderer::setVertexShaderConstantB(unsigned int index, const int *boolean, unsigned int count)
{
for(unsigned int i = 0; i < DRAW_COUNT; i++)
{
if(drawCall[i]->vsDirtyConstB < index + count)
{
drawCall[i]->vsDirtyConstB = index + count;
}
}
for(unsigned int i = 0; i < count; i++)
{
VertexProcessor::setBooleanConstant(index + i, *boolean);
boolean++;
}
}
void Renderer::addQuery(Query *query)
......
......@@ -294,16 +294,8 @@ namespace sw
void setRasterizerDiscard(bool rasterizerDiscard);
// Programmable pipelines
void setPixelShader(const PixelShader *shader);
void setVertexShader(const VertexShader *shader);
void setPixelShaderConstantF(unsigned int index, const float value[4], unsigned int count = 1);
void setPixelShaderConstantI(unsigned int index, const int value[4], unsigned int count = 1);
void setPixelShaderConstantB(unsigned int index, const int *boolean, unsigned int count = 1);
void setVertexShaderConstantF(unsigned int index, const float value[4], unsigned int count = 1);
void setVertexShaderConstantI(unsigned int index, const int value[4], unsigned int count = 1);
void setVertexShaderConstantB(unsigned int index, const int *boolean, unsigned int count = 1);
void setPixelShader(const SpirvShader *shader);
void setVertexShader(const SpirvShader *shader);
// Viewport & Clipper
void setViewport(const VkViewport &viewport);
......@@ -311,12 +303,6 @@ namespace sw
void setClipFlags(int flags);
void setClipPlane(unsigned int index, const float plane[4]);
// Partial transform
void setModelMatrix(const Matrix &M, int i = 0);
void setViewMatrix(const Matrix &V);
void setBaseMatrix(const Matrix &B);
void setProjectionMatrix(const Matrix &P);
void addQuery(Query *query);
void removeQuery(Query *query);
......@@ -357,9 +343,6 @@ namespace sw
void initializeThreads();
void terminateThreads();
void loadConstants(const VertexShader *vertexShader);
void loadConstants(const PixelShader *pixelShader);
Context *context;
Clipper *clipper;
Blitter *blitter;
......@@ -459,15 +442,6 @@ namespace sw
Resource *texture[TOTAL_IMAGE_UNITS];
Resource* pUniformBuffers[MAX_UNIFORM_BUFFER_BINDINGS];
Resource* vUniformBuffers[MAX_UNIFORM_BUFFER_BINDINGS];
Resource* transformFeedbackBuffers[MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS];
unsigned int vsDirtyConstF;
unsigned int vsDirtyConstI;
unsigned int vsDirtyConstB;
unsigned int psDirtyConstF;
unsigned int psDirtyConstI;
unsigned int psDirtyConstB;
std::list<Query*> *queries;
......
......@@ -21,6 +21,7 @@
#include "Pipeline/SetupRoutine.hpp"
#include "Pipeline/Constants.hpp"
#include "Vulkan/VkDebug.hpp"
#include "Pipeline/SpirvShader.hpp"
namespace sw
{
......@@ -73,7 +74,7 @@ namespace sw
{
State state;
bool vPosZW = (context->pixelShader && context->pixelShader->isVPosDeclared() && fullPixelPositionRegister);
bool vPosZW = (context->pixelShader && context->pixelShader->hasBuiltinInput(spv::BuiltInPosition));
state.isDrawPoint = context->isDrawPoint();
state.isDrawLine = context->isDrawLine();
......@@ -84,7 +85,7 @@ namespace sw
state.cullMode = context->cullMode;
state.twoSidedStencil = context->stencilActive() && context->twoSidedStencil;
state.slopeDepthBias = context->slopeDepthBias != 0.0f;
state.vFace = context->pixelShader && context->pixelShader->isVFaceDeclared();
state.vFace = context->pixelShader && context->pixelShader->hasBuiltinInput(spv::BuiltInFrontFacing);
state.positionRegister = Pos;
state.pointSizeRegister = Unused;
......@@ -92,8 +93,9 @@ namespace sw
state.multiSample = context->getMultiSampleCount();
state.rasterizerDiscard = context->rasterizerDiscard;
state.positionRegister = context->vertexShader->getPositionRegister();
state.pointSizeRegister = context->vertexShader->getPointSizeRegister();
//TODO: route properly
state.positionRegister = 0;//context->vertexShader->getPositionRegister();
state.pointSizeRegister = 1;//context->vertexShader->getPointSizeRegister();
for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
{
......@@ -107,37 +109,37 @@ namespace sw
const bool point = context->isDrawPoint();
for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
{
for(int component = 0; component < 4; component++)
{
const Shader::Semantic& semantic = context->pixelShader->getInput(interpolant, component);
if(semantic.active())
{
int input = interpolant;
for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{
if(semantic == context->vertexShader->getOutput(i, component))
{
input = i;
break;
}
}
bool flat = point;
switch(semantic.usage)
{
case Shader::USAGE_TEXCOORD: flat = false; break;
case Shader::USAGE_COLOR: flat = semantic.flat || point; break;
}
state.gradient[interpolant][component].attribute = input;
state.gradient[interpolant][component].flat = flat;
}
}
}
// for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
// {
// for(int component = 0; component < 4; component++)
// {
// const Shader::Semantic& semantic = context->pixelShader->getInput(interpolant, component);
//
// if(semantic.active())
// {
// int input = interpolant;
// for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
// {
// if(semantic == context->vertexShader->getOutput(i, component))
// {
// input = i;
// break;
// }
// }
//
// bool flat = point;
//
// switch(semantic.usage)
// {
// case Shader::USAGE_TEXCOORD: flat = false; break;
// case Shader::USAGE_COLOR: flat = semantic.flat || point; break;
// }
//
// state.gradient[interpolant][component].attribute = input;
// state.gradient[interpolant][component].flat = flat;
// }
// }
// }
state.hash = state.computeHash();
......
......@@ -17,8 +17,6 @@
#include "Context.hpp"
#include "RoutineCache.hpp"
#include "Pipeline/VertexShader.hpp"
#include "Pipeline/PixelShader.hpp"
#include "System/Types.hpp"
namespace sw
......
......@@ -15,8 +15,6 @@
#include "VertexProcessor.hpp"
#include "Pipeline/VertexProgram.hpp"
#include "Pipeline/VertexShader.hpp"
#include "Pipeline/PixelShader.hpp"
#include "Pipeline/Constants.hpp"
#include "System/Math.hpp"
#include "Vulkan/VkDebug.hpp"
......@@ -63,16 +61,6 @@ namespace sw
return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0;
}
VertexProcessor::TransformFeedbackInfo::TransformFeedbackInfo()
{
buffer = nullptr;
offset = 0;
reg = 0;
row = 0;
col = 0;
stride = 0;
}
VertexProcessor::UniformBufferInfo::UniformBufferInfo()
{
buffer = nullptr;
......@@ -152,29 +140,6 @@ namespace sw
}
}
void VertexProcessor::setTransformFeedbackBuffer(int index, sw::Resource* buffer, int offset, unsigned int reg, unsigned int row, unsigned int col, unsigned int stride)
{
transformFeedbackInfo[index].buffer = buffer;
transformFeedbackInfo[index].offset = offset;
transformFeedbackInfo[index].reg = reg;
transformFeedbackInfo[index].row = row;
transformFeedbackInfo[index].col = col;
transformFeedbackInfo[index].stride = stride;
}
void VertexProcessor::lockTransformFeedbackBuffers(byte** t, unsigned int* v, unsigned int* r, unsigned int* c, unsigned int* s, sw::Resource* transformFeedbackBuffers[])
{
for(int i = 0; i < MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; ++i)
{
t[i] = transformFeedbackInfo[i].buffer ? static_cast<byte*>(transformFeedbackInfo[i].buffer->lock(PUBLIC, PRIVATE)) + transformFeedbackInfo[i].offset : nullptr;
transformFeedbackBuffers[i] = transformFeedbackInfo[i].buffer;
v[i] = transformFeedbackInfo[i].reg;
r[i] = transformFeedbackInfo[i].row;
c[i] = transformFeedbackInfo[i].col;
s[i] = transformFeedbackInfo[i].stride;
}
}
void VertexProcessor::setInstanceID(int instanceID)
{
context->instanceID = instanceID;
......@@ -370,16 +335,6 @@ namespace sw
this->pointSizeMax = pointSizeMax;
}
void VertexProcessor::setTransformFeedbackQueryEnabled(bool enable)
{
context->transformFeedbackQueryEnabled = enable;
}
void VertexProcessor::enableTransformFeedback(uint64_t enable)
{
context->transformFeedbackEnabled = enable;
}
void VertexProcessor::setRoutineCacheSize(int cacheSize)
{
delete routineCache;
......@@ -391,49 +346,13 @@ namespace sw
State state;
state.shaderID = context->vertexShader->getSerialID();
state.fixedFunction = !context->vertexShader && context->pixelShaderModel() < 0x0300;
state.textureSampling = context->vertexShader ? context->vertexShader->containsTextureSampling() : false;
state.positionRegister = context->vertexShader ? context->vertexShader->getPositionRegister() : Pos;
state.pointSizeRegister = context->vertexShader ? context->vertexShader->getPointSizeRegister() : Pts;
state.multiSampling = context->getMultiSampleCount() > 1;
state.transformFeedbackQueryEnabled = context->transformFeedbackQueryEnabled;
state.transformFeedbackEnabled = context->transformFeedbackEnabled;
// Note: Quads aren't handled for verticesPerPrimitive, but verticesPerPrimitive is used for transform feedback,
// which is an OpenGL ES 3.0 feature, and OpenGL ES 3.0 doesn't support quads as a primitive type.
DrawType type = static_cast<DrawType>(static_cast<unsigned int>(drawType) & 0xF);
state.verticesPerPrimitive = 1 + (type >= DRAW_LINELIST) + (type >= DRAW_TRIANGLELIST);
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
state.input[i].type = context->input[i].type;
state.input[i].count = context->input[i].count;
state.input[i].normalized = context->input[i].normalized;
state.input[i].attribType = context->vertexShader ? context->vertexShader->getAttribType(i) : SpirvShader::ATTRIBTYPE_FLOAT;
}
for(unsigned int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++)
{
if(context->vertexShader->usesSampler(i))
{
state.sampler[i] = context->sampler[TEXTURE_IMAGE_UNITS + i].samplerState();
}
}
if(context->vertexShader) // FIXME: Also when pre-transformed?
{
for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{
state.output[i].xWrite = context->vertexShader->getOutput(i, 0).active();
state.output[i].yWrite = context->vertexShader->getOutput(i, 1).active();
state.output[i].zWrite = context->vertexShader->getOutput(i, 2).active();
state.output[i].wWrite = context->vertexShader->getOutput(i, 3).active();
}
}
state.hash = state.computeHash();
return state;
......
......@@ -18,7 +18,6 @@
#include "Matrix.hpp"
#include "Context.hpp"
#include "RoutineCache.hpp"
#include "Pipeline/VertexShader.hpp"
#include "Pipeline/SpirvShader.hpp"
namespace sw
......@@ -51,13 +50,9 @@ namespace sw
uint64_t shaderID;
bool fixedFunction : 1; // TODO: Eliminate by querying shader.
bool textureSampling : 1; // TODO: Eliminate by querying shader.
unsigned int positionRegister : BITS(MAX_VERTEX_OUTPUTS); // TODO: Eliminate by querying shader.
unsigned int pointSizeRegister : BITS(MAX_VERTEX_OUTPUTS); // TODO: Eliminate by querying shader.
bool transformFeedbackQueryEnabled : 1;
uint64_t transformFeedbackEnabled : 64;
unsigned char verticesPerPrimitive : 2; // 1 (points), 2 (lines) or 3 (triangles)
bool multiSampling : 1;
......@@ -164,9 +159,6 @@ namespace sw
void setPointSizeMin(float pointSizeMin);
void setPointSizeMax(float pointSizeMax);
void setTransformFeedbackQueryEnabled(bool enable);
void enableTransformFeedback(uint64_t enable);
protected:
const State update(DrawType drawType);
Routine *routine(const State &state);
......@@ -191,19 +183,6 @@ namespace sw
};
UniformBufferInfo uniformBufferInfo[MAX_UNIFORM_BUFFER_BINDINGS];
struct TransformFeedbackInfo
{
TransformFeedbackInfo();
Resource* buffer;
unsigned int offset;
unsigned int reg;
unsigned int row;
unsigned int col;
unsigned int stride;
};
TransformFeedbackInfo transformFeedbackInfo[MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS];
Context *const context;
RoutineCache<State> *routineCache;
......
......@@ -23,26 +23,9 @@ namespace sw
class PixelProgram : public PixelRoutine
{
public:
PixelProgram(const PixelProcessor::State &state, const PixelShader *shader) :
PixelRoutine(state, shader), r(shader->indirectAddressableTemporaries),
loopDepth(-1), ifDepth(0), loopRepDepth(0), currentLabel(-1), whileTest(false)
PixelProgram(const PixelProcessor::State &state, SpirvShader const *spirvShader) :
PixelRoutine(state, spirvShader)
{
for(int i = 0; i < 2048; ++i)
{
labelBlock[i] = 0;
}
enableStack[0] = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
if(shader->containsBreakInstruction())
{
enableBreak = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
}
if(shader->containsContinueInstruction())
{
enableContinue = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
}
}
virtual ~PixelProgram() {}
......@@ -54,116 +37,20 @@ namespace sw
virtual void rasterOperation(Float4 &fog, Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4]);
private:
// Temporary registers
RegisterArray<NUM_TEMPORARY_REGISTERS> r;
// Color outputs
Vector4f c[RENDERTARGETS];
RegisterArray<RENDERTARGETS, true> oC;
// Shader variables
Vector4f vPos;
Vector4f vFace;
// DX9 specific variables
Vector4f p0;
Array<Int, 4> aL;
Array<Int, 4> increment;
Array<Int, 4> iteration;
Int loopDepth; // FIXME: Add support for switch
Int stackIndex; // FIXME: Inc/decrement callStack
Array<UInt, 16> callStack;
// Per pixel based on conditions reached
Int enableIndex;
Array<Int4, 1 + 24> enableStack;
Int4 enableBreak;
Int4 enableContinue;
Int4 enableLeave;
Vector4f sampleTexture(const Src &sampler, Vector4f &uvwq, Float4 &bias, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
Vector4f sampleTexture(int samplerIndex, Vector4f &uvwq, Float4 &bias, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
// Raster operations
void clampColor(Vector4f oC[RENDERTARGETS]);
Int4 enableMask(const Shader::Instruction *instruction);
Vector4f fetchRegister(const Src &src, unsigned int offset = 0);
Vector4f readConstant(const Src &src, unsigned int offset = 0);
RValue<Pointer<Byte>> uniformAddress(int bufferIndex, unsigned int index);
RValue<Pointer<Byte>> uniformAddress(int bufferIndex, unsigned int index, Int& offset);
Int relativeAddress(const Shader::Relative &rel, int bufferIndex = -1);
Int4 dynamicAddress(const Shader::Relative &rel);
Int4 enableMask();
Float4 linearToSRGB(const Float4 &x);
// Instructions
typedef Shader::Control Control;
void M3X2(Vector4f &dst, Vector4f &src0, const Src &src1);
void M3X3(Vector4f &dst, Vector4f &src0, const Src &src1);
void M3X4(Vector4f &dst, Vector4f &src0, const Src &src1);
void M4X3(Vector4f &dst, Vector4f &src0, const Src &src1);
void M4X4(Vector4f &dst, Vector4f &src0, const Src &src1);
void TEX(Vector4f &dst, Vector4f &src0, const Src &src1, bool project, bool bias);
void TEXLOD(Vector4f &dst, Vector4f &src0, const Src &src1, Float4 &lod);
void TEXBIAS(Vector4f &dst, Vector4f &src0, const Src &src1, Float4 &bias);
void TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1);
void TEXKILL(Int cMask[4], Vector4f &src, unsigned char mask);
void TEXOFFSET(Vector4f &dst, Vector4f &src0, const Src &src1, Vector4f &offset);
void TEXOFFSETBIAS(Vector4f &dst, Vector4f &src0, const Src &src1, Vector4f &offset, Float4 &bias);
void TEXLODOFFSET(Vector4f &dst, Vector4f &src0, const Src &src1, Vector4f &offset, Float4 &lod);
void TEXELFETCH(Vector4f &dst, Vector4f &src, const Src &, Float4 &lod);
void TEXELFETCHOFFSET(Vector4f &dst, Vector4f &src, const Src &, Vector4f &offset, Float4 &lod);
void TEXGRAD(Vector4f &dst, Vector4f &src0, const Src &src1, Vector4f &dsx, Vector4f &dsy);
void TEXGRADOFFSET(Vector4f &dst, Vector4f &src, const Src &, Vector4f &dsx, Vector4f &dsy, Vector4f &offset);
void DISCARD(Int cMask[4], const Shader::Instruction *instruction);
void DFDX(Vector4f &dst, Vector4f &src);
void DFDY(Vector4f &dst, Vector4f &src);
void FWIDTH(Vector4f &dst, Vector4f &src);
void BREAK();
void BREAKC(Vector4f &src0, Vector4f &src1, Control);
void BREAKP(const Src &predicateRegister);
void BREAK(Int4 &condition);
void CONTINUE();
void TEST();
void CALL(int labelIndex, int callSiteIndex);
void CALLNZ(int labelIndex, int callSiteIndex, const Src &src);
void CALLNZb(int labelIndex, int callSiteIndex, const Src &boolRegister);
void CALLNZp(int labelIndex, int callSiteIndex, const Src &predicateRegister);
void ELSE();
void ENDIF();
void ENDLOOP();
void ENDREP();
void ENDWHILE();
void ENDSWITCH();
void IF(const Src &src);
void IFb(const Src &boolRegister);
void IFp(const Src &predicateRegister);
void IFC(Vector4f &src0, Vector4f &src1, Control);
void IF(Int4 &condition);
void LABEL(int labelIndex);
void LOOP(const Src &integerRegister);
void REP(const Src &integerRegister);
void WHILE(const Src &temporaryRegister);
void SWITCH();
void RET();
void LEAVE();
int ifDepth;
int loopRepDepth;
int currentLabel;
bool whileTest;
BasicBlock *ifFalseBlock[24 + 24];
BasicBlock *loopRepTestBlock[4];
BasicBlock *loopRepEndBlock[4];
BasicBlock *labelBlock[2048];
std::vector<BasicBlock*> callRetBlock[2048];
BasicBlock *returnBlock;
bool isConditionalIf[24 + 24];
};
}
......
......@@ -29,10 +29,10 @@ namespace sw
extern bool exactColorRounding;
extern bool forceClearRegisters;
PixelRoutine::PixelRoutine(const PixelProcessor::State &state, const PixelShader *shader)
: QuadRasterizer(state, shader), v(shader && shader->indirectAddressableInput)
PixelRoutine::PixelRoutine(const PixelProcessor::State &state, SpirvShader const *spirvShader)
: QuadRasterizer(state, spirvShader), v(true) /* addressing */
{
if(!shader || shader->getShaderModel() < 0x0200 || forceClearRegisters)
if(forceClearRegisters)
{
for(int i = 0; i < MAX_FRAGMENT_INPUTS; i++)
{
......@@ -142,6 +142,7 @@ namespace sw
}
}
// TODO: rethink what we want to do here for pull-mode interpolation
for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
{
for(int component = 0; component < 4; component++)
......@@ -210,7 +211,7 @@ namespace sw
alphaPass = alphaTest(cMask);
if((shader && shader->containsKill()) || state.alphaTestActive())
if((spirvShader && spirvShader->getModes().ContainsKill) || state.alphaTestActive())
{
for(unsigned int q = 0; q < state.multiSample; q++)
{
......@@ -394,7 +395,7 @@ namespace sw
Float4 Z = z;
if(shader && shader->depthOverride())
if(spirvShader && spirvShader->getModes().DepthReplacing)
{
if(complementaryDepthBuffer)
{
......@@ -592,7 +593,7 @@ namespace sw
Float4 Z = z;
if(shader && shader->depthOverride())
if(spirvShader && spirvShader->getModes().DepthReplacing)
{
if(complementaryDepthBuffer)
{
......@@ -2479,6 +2480,6 @@ namespace sw
bool PixelRoutine::colorUsed()
{
return state.colorWriteMask || state.alphaTestActive() || state.shaderContainsKill;
return state.colorWriteMask || state.alphaTestActive() || (spirvShader && spirvShader->getModes().ContainsKill);
}
}
......@@ -25,7 +25,7 @@ namespace sw
class PixelRoutine : public sw::QuadRasterizer, public ShaderCore
{
public:
PixelRoutine(const PixelProcessor::State &state, const PixelShader *shader);
PixelRoutine(const PixelProcessor::State &state, SpirvShader const *spirvShader);
virtual ~PixelRoutine();
......@@ -39,9 +39,6 @@ namespace sw
// Depth output
Float4 oDepth;
typedef Shader::SourceParameter Src;
typedef Shader::DestinationParameter Dst;
virtual void setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w) = 0;
virtual void applyShader(Int cMask[4]) = 0;
virtual Bool alphaTest(Int cMask[4]) = 0;
......
// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef sw_PixelShader_hpp
#define sw_PixelShader_hpp
#include "Shader.hpp"
#include "Device/Config.hpp"
namespace sw
{
class PixelShader : public Shader
{
public:
explicit PixelShader(const PixelShader *ps = 0);
explicit PixelShader(const unsigned long *token);
virtual ~PixelShader();
static int validate(const unsigned long *const token); // Returns number of instructions if valid
bool depthOverride() const;
bool containsKill() const;
bool containsCentroid() const;
bool usesDiffuse(int component) const;
bool usesSpecular(int component) const;
bool usesTexture(int coordinate, int component) const;
void setInput(int inputIdx, int nbComponents, const Semantic& semantic);
const Semantic& getInput(int inputIdx, int component) const;
void declareVPos() { vPosDeclared = true; }
void declareVFace() { vFaceDeclared = true; }
bool isVPosDeclared() const { return vPosDeclared; }
bool isVFaceDeclared() const { return vFaceDeclared; }
private:
void analyze();
void analyzeZOverride();
void analyzeKill();
void analyzeInterpolants();
Semantic input[MAX_FRAGMENT_INPUTS][4];
bool vPosDeclared;
bool vFaceDeclared;
bool zOverride;
bool kill;
bool centroid;
};
}
#endif // sw_PixelShader_hpp
......@@ -1809,37 +1809,37 @@ namespace sw
{
switch(control)
{
case Shader::CONTROL_GT:
case CONTROL_GT:
dst.x = As<Float4>(CmpNLE(src0.x, src1.x));
dst.y = As<Float4>(CmpNLE(src0.y, src1.y));
dst.z = As<Float4>(CmpNLE(src0.z, src1.z));
dst.w = As<Float4>(CmpNLE(src0.w, src1.w));
break;
case Shader::CONTROL_EQ:
case CONTROL_EQ:
dst.x = As<Float4>(CmpEQ(src0.x, src1.x));
dst.y = As<Float4>(CmpEQ(src0.y, src1.y));
dst.z = As<Float4>(CmpEQ(src0.z, src1.z));
dst.w = As<Float4>(CmpEQ(src0.w, src1.w));
break;
case Shader::CONTROL_GE:
case CONTROL_GE:
dst.x = As<Float4>(CmpNLT(src0.x, src1.x));
dst.y = As<Float4>(CmpNLT(src0.y, src1.y));
dst.z = As<Float4>(CmpNLT(src0.z, src1.z));
dst.w = As<Float4>(CmpNLT(src0.w, src1.w));
break;
case Shader::CONTROL_LT:
case CONTROL_LT:
dst.x = As<Float4>(CmpLT(src0.x, src1.x));
dst.y = As<Float4>(CmpLT(src0.y, src1.y));
dst.z = As<Float4>(CmpLT(src0.z, src1.z));
dst.w = As<Float4>(CmpLT(src0.w, src1.w));
break;
case Shader::CONTROL_NE:
case CONTROL_NE:
dst.x = As<Float4>(CmpNEQ(src0.x, src1.x));
dst.y = As<Float4>(CmpNEQ(src0.y, src1.y));
dst.z = As<Float4>(CmpNEQ(src0.z, src1.z));
dst.w = As<Float4>(CmpNEQ(src0.w, src1.w));
break;
case Shader::CONTROL_LE:
case CONTROL_LE:
dst.x = As<Float4>(CmpLE(src0.x, src1.x));
dst.y = As<Float4>(CmpLE(src0.y, src1.y));
dst.z = As<Float4>(CmpLE(src0.z, src1.z));
......@@ -1854,37 +1854,37 @@ namespace sw
{
switch(control)
{
case Shader::CONTROL_GT:
case CONTROL_GT:
dst.x = As<Float4>(CmpNLE(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpNLE(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpNLE(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpNLE(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case Shader::CONTROL_EQ:
case CONTROL_EQ:
dst.x = As<Float4>(CmpEQ(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpEQ(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpEQ(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpEQ(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case Shader::CONTROL_GE:
case CONTROL_GE:
dst.x = As<Float4>(CmpNLT(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpNLT(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpNLT(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpNLT(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case Shader::CONTROL_LT:
case CONTROL_LT:
dst.x = As<Float4>(CmpLT(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpLT(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpLT(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpLT(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case Shader::CONTROL_NE:
case CONTROL_NE:
dst.x = As<Float4>(CmpNEQ(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpNEQ(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpNEQ(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpNEQ(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case Shader::CONTROL_LE:
case CONTROL_LE:
dst.x = As<Float4>(CmpLE(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpLE(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpLE(As<Int4>(src0.z), As<Int4>(src1.z)));
......@@ -1899,37 +1899,37 @@ namespace sw
{
switch(control)
{
case Shader::CONTROL_GT:
case CONTROL_GT:
dst.x = As<Float4>(CmpNLE(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpNLE(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpNLE(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpNLE(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case Shader::CONTROL_EQ:
case CONTROL_EQ:
dst.x = As<Float4>(CmpEQ(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpEQ(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpEQ(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpEQ(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case Shader::CONTROL_GE:
case CONTROL_GE:
dst.x = As<Float4>(CmpNLT(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpNLT(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpNLT(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpNLT(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case Shader::CONTROL_LT:
case CONTROL_LT:
dst.x = As<Float4>(CmpLT(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpLT(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpLT(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpLT(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case Shader::CONTROL_NE:
case CONTROL_NE:
dst.x = As<Float4>(CmpNEQ(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpNEQ(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpNEQ(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpNEQ(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case Shader::CONTROL_LE:
case CONTROL_LE:
dst.x = As<Float4>(CmpLE(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpLE(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpLE(As<UInt4>(src0.z), As<UInt4>(src1.z)));
......
......@@ -15,7 +15,6 @@
#ifndef sw_ShaderCore_hpp
#define sw_ShaderCore_hpp
#include "Shader.hpp"
#include "Reactor/Reactor.hpp"
#include "Vulkan/VkDebug.hpp"
......@@ -234,7 +233,18 @@ namespace sw
class ShaderCore
{
typedef Shader::Control Control;
enum Control
{
CONTROL_RESERVED0,
CONTROL_GT,
CONTROL_EQ,
CONTROL_GE,
CONTROL_LT,
CONTROL_NE,
CONTROL_LE,
CONTROL_RESERVED1
};
public:
void mov(Vector4f &dst, const Vector4f &src, bool integerDestination = false);
......
......@@ -25,99 +25,25 @@
namespace sw
{
struct Stream;
class VertexShader;
class VertexProgram : public VertexRoutine, public ShaderCore
{
public:
VertexProgram(const VertexProcessor::State &state, const VertexShader *vertexShader);
VertexProgram(const VertexProcessor::State &state, SpirvShader const *spirvShader);
virtual ~VertexProgram();
private:
const VertexShader *const shader;
RegisterArray<NUM_TEMPORARY_REGISTERS> r; // Temporary registers
Vector4f a0;
Array<Int, 4> aL;
Vector4f p0;
Array<Int, 4> increment;
Array<Int, 4> iteration;
Int loopDepth;
Int stackIndex; // FIXME: Inc/decrement callStack
Array<UInt, 16> callStack;
Int enableIndex;
Array<Int4, 1 + 24> enableStack;
Int4 enableBreak;
Int4 enableContinue;
Int4 enableLeave;
Int instanceID;
Int4 vertexID;
typedef Shader::DestinationParameter Dst;
typedef Shader::SourceParameter Src;
typedef Shader::Control Control;
typedef Shader::Usage Usage;
void program(UInt &index) override;
Vector4f fetchRegister(const Src &src, unsigned int offset = 0);
Vector4f readConstant(const Src &src, unsigned int offset = 0);
RValue<Pointer<Byte>> uniformAddress(int bufferIndex, unsigned int index);
RValue<Pointer<Byte>> uniformAddress(int bufferIndex, unsigned int index, Int &offset);
Int relativeAddress(const Shader::Relative &rel, int bufferIndex = -1);
Int4 dynamicAddress(const Shader::Relative &rel);
Int4 enableMask(const Shader::Instruction *instruction);
void M3X2(Vector4f &dst, Vector4f &src0, Src &src1);
void M3X3(Vector4f &dst, Vector4f &src0, Src &src1);
void M3X4(Vector4f &dst, Vector4f &src0, Src &src1);
void M4X3(Vector4f &dst, Vector4f &src0, Src &src1);
void M4X4(Vector4f &dst, Vector4f &src0, Src &src1);
void BREAK();
void BREAKC(Vector4f &src0, Vector4f &src1, Control);
void BREAKP(const Src &predicateRegister);
void BREAK(Int4 &condition);
void CONTINUE();
void TEST();
void CALL(int labelIndex, int callSiteIndex);
void CALLNZ(int labelIndex, int callSiteIndex, const Src &src);
void CALLNZb(int labelIndex, int callSiteIndex, const Src &boolRegister);
void CALLNZp(int labelIndex, int callSiteIndex, const Src &predicateRegister);
void ELSE();
void ENDIF();
void ENDLOOP();
void ENDREP();
void ENDWHILE();
void ENDSWITCH();
void IF(const Src &src);
void IFb(const Src &boolRegister);
void IFp(const Src &predicateRegister);
void IFC(Vector4f &src0, Vector4f &src1, Control);
void IF(Int4 &condition);
void LABEL(int labelIndex);
void LOOP(const Src &integerRegister);
void REP(const Src &integerRegister);
void WHILE(const Src &temporaryRegister);
void SWITCH();
void RET();
void LEAVE();
void TEX(Vector4f &dst, Vector4f &src, const Src&);
void TEXOFFSET(Vector4f &dst, Vector4f &src, const Src&, Vector4f &offset);
void TEXLOD(Vector4f &dst, Vector4f &src, const Src&, Float4 &lod);
void TEXLODOFFSET(Vector4f &dst, Vector4f &src, const Src&, Vector4f &offset, Float4 &lod);
void TEXELFETCH(Vector4f &dst, Vector4f &src, const Src&, Float4 &lod);
void TEXELFETCHOFFSET(Vector4f &dst, Vector4f &src, const Src&, Vector4f &offset, Float4 &lod);
void TEXGRAD(Vector4f &dst, Vector4f &src, const Src&, Vector4f &dsx, Vector4f &dsy);
void TEXGRADOFFSET(Vector4f &dst, Vector4f &src, const Src&, Vector4f &dsx, Vector4f &dsy, Vector4f &offset);
void TEXSIZE(Vector4f &dst, Float4 &lod, const Src&);
Vector4f sampleTexture(const Src &s, Vector4f &uvwq, Float4 &lod, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
Vector4f sampleTexture(int sampler, Vector4f &uvwq, Float4 &lod, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerFunction function);
Int4 enableMask();
int ifDepth;
int loopRepDepth;
......
......@@ -14,7 +14,6 @@
#include "VertexRoutine.hpp"
#include "VertexShader.hpp"
#include "Constants.hpp"
#include "Device/Vertex.hpp"
#include "Device/Renderer.hpp"
......@@ -23,13 +22,11 @@
namespace sw
{
extern bool halfIntegerCoordinates; // Pixel centers are not at integer coordinates
extern bool symmetricNormalizedDepth; // [-1, 1] instead of [0, 1]
VertexRoutine::VertexRoutine(const VertexProcessor::State &state, const VertexShader *shader)
: v(shader && shader->indirectAddressableInput),
o(shader && shader->indirectAddressableOutput),
state(state)
VertexRoutine::VertexRoutine(const VertexProcessor::State &state, SpirvShader const *spirvShader)
: v(true), /* TODO: indirect addressable */
o(true),
state(state),
spirvShader(spirvShader)
{
}
......@@ -63,7 +60,6 @@ namespace sw
readInput(indexQ);
program(indexQ);
postTransform();
computeClipFlags();
Pointer<Byte> cacheLine0 = vertexCache + tagIndex * UInt((int)sizeof(Vertex));
......@@ -74,18 +70,6 @@ namespace sw
Pointer<Byte> cacheLine = vertexCache + cacheIndex * UInt((int)sizeof(Vertex));
writeVertex(vertex, cacheLine);
if(state.transformFeedbackEnabled != 0)
{
transformFeedback(vertex, primitiveNumber, indexInPrimitive);
indexInPrimitive++;
If(indexInPrimitive == 3)
{
primitiveNumber++;
indexInPrimitive = 0;
}
}
vertex += sizeof(Vertex);
batch += sizeof(unsigned int);
vertexCount--;
......@@ -603,17 +587,6 @@ namespace sw
return v;
}
void VertexRoutine::postTransform()
{
int pos = state.positionRegister;
if(!halfIntegerCoordinates)
{
o[pos].x = o[pos].x + *Pointer<Float4>(data + OFFSET(DrawData,halfPixelX)) * o[pos].w;
o[pos].y = o[pos].y + *Pointer<Float4>(data + OFFSET(DrawData,halfPixelY)) * o[pos].w;
}
}
void VertexRoutine::writeCache(Pointer<Byte> &cacheLine)
{
Vector4f v;
......@@ -719,38 +692,4 @@ namespace sw
*Pointer<Int4>(vertex + OFFSET(Vertex,X)) = *Pointer<Int4>(cache + OFFSET(Vertex,X));
*Pointer<Int>(vertex + OFFSET(Vertex,clipFlags)) = *Pointer<Int>(cache + OFFSET(Vertex,clipFlags));
}
void VertexRoutine::transformFeedback(const Pointer<Byte> &vertex, const UInt &primitiveNumber, const UInt &indexInPrimitive)
{
If(indexInPrimitive < state.verticesPerPrimitive)
{
UInt tOffset = primitiveNumber * state.verticesPerPrimitive + indexInPrimitive;
for(int i = 0; i < MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; i++)
{
if(state.transformFeedbackEnabled & (1ULL << i))
{
UInt reg = *Pointer<UInt>(data + OFFSET(DrawData, vs.reg[i]));
UInt row = *Pointer<UInt>(data + OFFSET(DrawData, vs.row[i]));
UInt col = *Pointer<UInt>(data + OFFSET(DrawData, vs.col[i]));
UInt str = *Pointer<UInt>(data + OFFSET(DrawData, vs.str[i]));
Pointer<Byte> t = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData, vs.t[i])) + (tOffset * str * sizeof(float));
Pointer<Byte> v = vertex + OFFSET(Vertex, v) + reg * sizeof(float);
For(UInt r = 0, r < row, r++)
{
UInt rOffsetX = r * col * sizeof(float);
UInt rOffset4 = r * sizeof(float4);
For(UInt c = 0, c < col, c++)
{
UInt cOffset = c * sizeof(float);
*Pointer<Float>(t + rOffsetX + cOffset) = *Pointer<Float>(v + rOffset4 + cOffset);
}
}
}
}
}
}
}
......@@ -18,7 +18,7 @@
#include "Device/Color.hpp"
#include "Device/VertexProcessor.hpp"
#include "ShaderCore.hpp"
#include "VertexShader.hpp"
#include "SpirvShader.hpp"
namespace sw
{
......@@ -38,7 +38,7 @@ namespace sw
class VertexRoutine : public VertexRoutinePrototype
{
public:
VertexRoutine(const VertexProcessor::State &state, const VertexShader *shader);
VertexRoutine(const VertexProcessor::State &state, SpirvShader const *spirvShader);
virtual ~VertexRoutine();
void generate();
......@@ -52,6 +52,7 @@ namespace sw
RegisterArray<MAX_VERTEX_OUTPUTS> o; // Output registers
const VertexProcessor::State &state;
SpirvShader const * const spirvShader;
private:
virtual void program(UInt &index) = 0;
......@@ -61,10 +62,8 @@ namespace sw
Vector4f readStream(Pointer<Byte> &buffer, UInt &stride, const Stream &stream, const UInt &index);
void readInput(UInt &index);
void computeClipFlags();
void postTransform();
void writeCache(Pointer<Byte> &cacheLine);
void writeVertex(const Pointer<Byte> &vertex, Pointer<Byte> &cacheLine);
void transformFeedback(const Pointer<Byte> &vertex, const UInt &primitiveNumber, const UInt &indexInPrimitive);
};
}
......
// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "VertexShader.hpp"
#include "Device/Vertex.hpp"
#include "Vulkan/VkDebug.hpp"
#include <string.h>
namespace sw
{
VertexShader::VertexShader(const VertexShader *vs) : Shader()
{
shaderModel = 0x0300;
positionRegister = Pos;
pointSizeRegister = Unused;
instanceIdDeclared = false;
vertexIdDeclared = false;
textureSampling = false;
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
input[i] = Semantic();
attribType[i] = SpirvShader::ATTRIBTYPE_FLOAT;
}
if(vs) // Make a copy
{
for(size_t i = 0; i < vs->getLength(); i++)
{
append(new sw::Shader::Instruction(*vs->getInstruction(i)));
}
memcpy(output, vs->output, sizeof(output));
memcpy(input, vs->input, sizeof(input));
memcpy(attribType, vs->attribType, sizeof(attribType));
positionRegister = vs->positionRegister;
pointSizeRegister = vs->pointSizeRegister;
instanceIdDeclared = vs->instanceIdDeclared;
vertexIdDeclared = vs->vertexIdDeclared;
usedSamplers = vs->usedSamplers;
optimize();
analyze();
}
}
VertexShader::VertexShader(const unsigned long *token) : Shader()
{
parse(token);
positionRegister = Pos;
pointSizeRegister = Unused;
instanceIdDeclared = false;
vertexIdDeclared = false;
textureSampling = false;
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
input[i] = Semantic();
attribType[i] = SpirvShader::ATTRIBTYPE_FLOAT;
}
optimize();
analyze();
}
VertexShader::~VertexShader()
{
}
int VertexShader::validate(const unsigned long *const token)
{
if(!token)
{
return 0;
}
unsigned short version = (unsigned short)(token[0] & 0x0000FFFF);
unsigned char majorVersion = (unsigned char)((token[0] & 0x0000FF00) >> 8);
ShaderType shaderType = (ShaderType)((token[0] & 0xFFFF0000) >> 16);
if(shaderType != SHADER_VERTEX || majorVersion > 3)
{
return 0;
}
int instructionCount = 1;
for(int i = 0; token[i] != 0x0000FFFF; i++)
{
if((token[i] & 0x0000FFFF) == 0x0000FFFE) // Comment token
{
int length = (token[i] & 0x7FFF0000) >> 16;
i += length;
}
else
{
Shader::Opcode opcode = (Shader::Opcode)(token[i] & 0x0000FFFF);
switch(opcode)
{
case Shader::OPCODE_TEXCOORD:
case Shader::OPCODE_TEXKILL:
case Shader::OPCODE_TEX:
case Shader::OPCODE_TEXBEM:
case Shader::OPCODE_TEXBEML:
case Shader::OPCODE_TEXREG2AR:
case Shader::OPCODE_TEXREG2GB:
case Shader::OPCODE_TEXM3X2PAD:
case Shader::OPCODE_TEXM3X2TEX:
case Shader::OPCODE_TEXM3X3PAD:
case Shader::OPCODE_TEXM3X3TEX:
case Shader::OPCODE_RESERVED0:
case Shader::OPCODE_TEXM3X3SPEC:
case Shader::OPCODE_TEXM3X3VSPEC:
case Shader::OPCODE_TEXREG2RGB:
case Shader::OPCODE_TEXDP3TEX:
case Shader::OPCODE_TEXM3X2DEPTH:
case Shader::OPCODE_TEXDP3:
case Shader::OPCODE_TEXM3X3:
case Shader::OPCODE_TEXDEPTH:
case Shader::OPCODE_CMP0:
case Shader::OPCODE_BEM:
case Shader::OPCODE_DP2ADD:
case Shader::OPCODE_DFDX:
case Shader::OPCODE_DFDY:
case Shader::OPCODE_TEXLDD:
return 0; // Unsupported operation
default:
instructionCount++;
break;
}
i += size(token[i], version);
}
}
return instructionCount;
}
bool VertexShader::containsTextureSampling() const
{
return textureSampling;
}
void VertexShader::setInput(int inputIdx, const sw::Shader::Semantic& semantic, SpirvShader::AttribType aType)
{
input[inputIdx] = semantic;
attribType[inputIdx] = aType;
}
void VertexShader::setOutput(int outputIdx, int nbComponents, const sw::Shader::Semantic& semantic)
{
for(int i = 0; i < nbComponents; ++i)
{
output[outputIdx][i] = semantic;
}
}
void VertexShader::setPositionRegister(int posReg)
{
setOutput(posReg, 4, sw::Shader::Semantic(sw::Shader::USAGE_POSITION, 0));
positionRegister = posReg;
}
void VertexShader::setPointSizeRegister(int ptSizeReg)
{
setOutput(ptSizeReg, 4, sw::Shader::Semantic(sw::Shader::USAGE_PSIZE, 0));
pointSizeRegister = ptSizeReg;
}
const sw::Shader::Semantic& VertexShader::getInput(int inputIdx) const
{
return input[inputIdx];
}
SpirvShader::AttribType VertexShader::getAttribType(int inputIdx) const
{
return attribType[inputIdx];
}
const sw::Shader::Semantic& VertexShader::getOutput(int outputIdx, int component) const
{
return output[outputIdx][component];
}
void VertexShader::analyze()
{
analyzeInput();
analyzeOutput();
analyzeDirtyConstants();
analyzeTextureSampling();
analyzeDynamicBranching();
analyzeSamplers();
analyzeCallSites();
analyzeIndirectAddressing();
}
void VertexShader::analyzeInput()
{
for(unsigned int i = 0; i < instruction.size(); i++)
{
if(instruction[i]->opcode == Shader::OPCODE_DCL &&
instruction[i]->dst.type == Shader::PARAMETER_INPUT)
{
int index = instruction[i]->dst.index;
input[index] = Semantic(instruction[i]->usage, instruction[i]->usageIndex);
}
}
}
void VertexShader::analyzeOutput()
{
if(shaderModel < 0x0300)
{
output[Pos][0] = Semantic(Shader::USAGE_POSITION, 0);
output[Pos][1] = Semantic(Shader::USAGE_POSITION, 0);
output[Pos][2] = Semantic(Shader::USAGE_POSITION, 0);
output[Pos][3] = Semantic(Shader::USAGE_POSITION, 0);
for(const auto &inst : instruction)
{
const DestinationParameter &dst = inst->dst;
switch(dst.type)
{
case Shader::PARAMETER_RASTOUT:
switch(dst.index)
{
case 0:
// Position already assumed written
break;
case 1:
output[Fog][0] = Semantic(Shader::USAGE_FOG, 0);
break;
case 2:
output[Pts][1] = Semantic(Shader::USAGE_PSIZE, 0);
pointSizeRegister = Pts;
break;
default: ASSERT(false);
}
break;
case Shader::PARAMETER_ATTROUT:
if(dst.index == 0)
{
if(dst.x) output[C0][0] = Semantic(Shader::USAGE_COLOR, 0);
if(dst.y) output[C0][1] = Semantic(Shader::USAGE_COLOR, 0);
if(dst.z) output[C0][2] = Semantic(Shader::USAGE_COLOR, 0);
if(dst.w) output[C0][3] = Semantic(Shader::USAGE_COLOR, 0);
}
else if(dst.index == 1)
{
if(dst.x) output[C1][0] = Semantic(Shader::USAGE_COLOR, 1);
if(dst.y) output[C1][1] = Semantic(Shader::USAGE_COLOR, 1);
if(dst.z) output[C1][2] = Semantic(Shader::USAGE_COLOR, 1);
if(dst.w) output[C1][3] = Semantic(Shader::USAGE_COLOR, 1);
}
else ASSERT(false);
break;
case Shader::PARAMETER_TEXCRDOUT:
if(dst.x) output[T0 + dst.index][0] = Semantic(Shader::USAGE_TEXCOORD, dst.index);
if(dst.y) output[T0 + dst.index][1] = Semantic(Shader::USAGE_TEXCOORD, dst.index);
if(dst.z) output[T0 + dst.index][2] = Semantic(Shader::USAGE_TEXCOORD, dst.index);
if(dst.w) output[T0 + dst.index][3] = Semantic(Shader::USAGE_TEXCOORD, dst.index);
break;
default:
break;
}
}
}
else // Shader Model 3.0 input declaration
{
for(const auto &inst : instruction)
{
if(inst->opcode == Shader::OPCODE_DCL &&
inst->dst.type == Shader::PARAMETER_OUTPUT)
{
unsigned char usage = inst->usage;
unsigned char usageIndex = inst->usageIndex;
const DestinationParameter &dst = inst->dst;
if(dst.x) output[dst.index][0] = Semantic(usage, usageIndex);
if(dst.y) output[dst.index][1] = Semantic(usage, usageIndex);
if(dst.z) output[dst.index][2] = Semantic(usage, usageIndex);
if(dst.w) output[dst.index][3] = Semantic(usage, usageIndex);
if(usage == Shader::USAGE_POSITION && usageIndex == 0)
{
positionRegister = dst.index;
}
if(usage == Shader::USAGE_PSIZE && usageIndex == 0)
{
pointSizeRegister = dst.index;
}
}
}
}
}
void VertexShader::analyzeTextureSampling()
{
textureSampling = false;
for(const auto &inst : instruction)
{
if(inst->src[1].type == PARAMETER_SAMPLER)
{
textureSampling = true;
break;
}
}
}
}
// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef sw_VertexShader_hpp
#define sw_VertexShader_hpp
#include "Shader.hpp"
#include "SpirvShader.hpp"
#include "Device/Config.hpp"
namespace sw
{
class VertexShader : public Shader
{
public:
explicit VertexShader(const VertexShader *vs = 0);
explicit VertexShader(const unsigned long *token);
virtual ~VertexShader();
static int validate(const unsigned long *const token); // Returns number of instructions if valid
bool containsTextureSampling() const;
void setInput(int inputIdx, const Semantic& semantic, SpirvShader::AttribType attribType = SpirvShader::ATTRIBTYPE_FLOAT);
void setOutput(int outputIdx, int nbComponents, const Semantic& semantic);
void setPositionRegister(int posReg);
void setPointSizeRegister(int ptSizeReg);
void declareInstanceId() { instanceIdDeclared = true; }
void declareVertexId() { vertexIdDeclared = true; }
const Semantic& getInput(int inputIdx) const;
const Semantic& getOutput(int outputIdx, int component) const;
SpirvShader::AttribType getAttribType(int inputIndex) const;
int getPositionRegister() const { return positionRegister; }
int getPointSizeRegister() const { return pointSizeRegister; }
bool isInstanceIdDeclared() const { return instanceIdDeclared; }
bool isVertexIdDeclared() const { return vertexIdDeclared; }
private:
void analyze();
void analyzeInput();
void analyzeOutput();
void analyzeTextureSampling();
Semantic input[MAX_VERTEX_INPUTS];
Semantic output[MAX_VERTEX_OUTPUTS][4];
SpirvShader::AttribType attribType[MAX_VERTEX_INPUTS];
int positionRegister;
int pointSizeRegister;
bool instanceIdDeclared;
bool vertexIdDeclared;
bool textureSampling;
};
}
#endif // sw_VertexShader_hpp
......@@ -395,11 +395,11 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks* pAllocator, c
switch (pStage->stage) {
case VK_SHADER_STAGE_VERTEX_BIT:
vertexShader = spirvShader;
context.vertexShader = vertexShader = spirvShader;
break;
case VK_SHADER_STAGE_FRAGMENT_BIT:
fragmentShader = spirvShader;
context.pixelShader = fragmentShader = spirvShader;
break;
default:
......
......@@ -70,9 +70,6 @@ private:
sw::SpirvShader *vertexShader = nullptr;
sw::SpirvShader *fragmentShader = nullptr;
rr::Routine* vertexRoutine;
rr::Routine* fragmentRoutine;
sw::Context context;
sw::Rect scissor;
VkViewport viewport;
......
......@@ -143,15 +143,12 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ClCompile Include="..\Pipeline\Constants.cpp" />
<ClCompile Include="..\Pipeline\PixelProgram.cpp" />
<ClCompile Include="..\Pipeline\PixelRoutine.cpp" />
<ClCompile Include="..\Pipeline\PixelShader.cpp" />
<ClCompile Include="..\Pipeline\SamplerCore.cpp" />
<ClCompile Include="..\Pipeline\SetupRoutine.cpp" />
<ClCompile Include="..\Pipeline\Shader.cpp" />
<ClCompile Include="..\Pipeline\ShaderCore.cpp" />
<ClCompile Include="..\Pipeline\SpirvShader.cpp" />
<ClCompile Include="..\Pipeline\VertexProgram.cpp" />
<ClCompile Include="..\Pipeline\VertexRoutine.cpp" />
<ClCompile Include="..\Pipeline\VertexShader.cpp" />
<ClCompile Include="..\System\Configurator.cpp" />
<ClCompile Include="..\System\CPUID.cpp" />
<ClCompile Include="..\System\Debug.cpp" />
......@@ -253,16 +250,13 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ClInclude Include="..\Pipeline\Constants.hpp" />
<ClInclude Include="..\Pipeline\PixelProgram.hpp" />
<ClInclude Include="..\Pipeline\PixelRoutine.hpp" />
<ClInclude Include="..\Pipeline\PixelShader.hpp" />
<ClInclude Include="..\Pipeline\SamplerCore.hpp" />
<ClInclude Include="..\Pipeline\SetupRoutine.hpp" />
<ClInclude Include="..\Pipeline\Shader.hpp" />
<ClInclude Include="..\Pipeline\ShaderCore.hpp" />
<ClInclude Include="..\Pipeline\SpirvShader.hpp" />
<ClInclude Include="..\Pipeline\VertexPipeline.hpp" />
<ClInclude Include="..\Pipeline\VertexProgram.hpp" />
<ClInclude Include="..\Pipeline\VertexRoutine.hpp" />
<ClInclude Include="..\Pipeline\VertexShader.hpp" />
<ClInclude Include="..\System\Configurator.hpp" />
<ClInclude Include="..\System\CPUID.hpp" />
<ClInclude Include="..\System\Debug.hpp" />
......
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